Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3227504
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:34:57+00:00 2026-05-17T16:34:57+00:00

I was recently checking implementation of the j.u.c.CopyOnWriteArrayList in OpenJDK’s sources and found that

  • 0

I was recently checking implementation of the j.u.c.CopyOnWriteArrayList in OpenJDK’s sources and found that the lock variable defined inside the class, is redeclared with following statement

final ReentrantLock lock = this.lock;

inside all the methods which requires this variable. Any specific reason for doing such redeclaration of the variable (which is possibly hiding global variable). Cant we simply use object’s ‘lock’ field directly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:34:57+00:00Added an answer on May 17, 2026 at 4:34 pm

    That is just a micro optimization technique. In theory, access to a local variable is faster then access to field and it may also result to a smaller bytecode. Though HotSpot compiler may actually optimize field access to a register call, so it won’t be different.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently, I was writing a class in which I discovered that I could reduce
Recently I was checking up on some AI possibilities and found out about babel-lang
I have recently started using DocCheck for checking the validity of JavaDoc's in code
Recently I've found how to add a link to an item in Visual Studio
I recently run into a problem where records were marked as readonly. Checking out
I recently wrote an extremely basic edge detection algorithm that works on an array
I was running my project and was checking recently modified module. On click of
I have recently had a few issues when checking out a colleagues ASP.NET project,
Recently I've implemented an application in Java that uses the Google Docs API v3.0
Recently working on my company i'm realize that start to having troubles with some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.