[concurrency-interest] Stupid Question

javamann at cox.net javamann at cox.net
Tue Feb 12 16:12:59 EST 2013

Thanks, this is why I really like this list.


---- Nathan Reynolds <nathan.reynolds at oracle.com> wrote: 

this.lock is a memory indirection (i.e. dereferences "this" to get the 
value in "lock") and could incur a cache miss (i.e. loads 
ArrayBlockQueue into the L1 cache) or even worse false sharing.  By 
copying to the local variable, the value is on the stack.  There won't 
be any memory indirection to access the value.  Cache misses would only 
happen if the thread context switched.  False sharing is impossible.

Nathan Reynolds 
<http://psr.us.oracle.com/wiki/index.php/User:Nathan_Reynolds> | 
Architect | 602.333.9091
Oracle PSR Engineering <http://psr.us.oracle.com/> | Server Technology
On 2/12/2013 1:41 PM, javamann at cox.net wrote:
> Stupid question time. While going through the code for an ArrayBlockQueue I came across numerous instances where the instance 'lock' is copied to a variable in a Method. I know there is a reason for this, I just don't know what it is.
> Thanks
> -Pete
>      public int remainingCapacity() {
>          final ReentrantLock lock = this.lock;
>          lock.lock();
>          try {
>              return items.length - count;
>          } finally {
>              lock.unlock();
>          }
>      }
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest


1. If a man is standing in the middle of the forest talking, and there is no woman around to hear him, is he still wrong?

2. Behind every great woman... Is a man checking out her ass

3. I am not a member of any organized political party. I am a Democrat.*

4. Diplomacy is the art of saying "Nice doggie" until you can find a rock.*

5. A process is what you need when all your good people have left.

*Will Rogers

More information about the Concurrency-interest mailing list