[concurrency-interest] Making copy of a reference to ReentrantLock

Joe Bowbeer joe.bowbeer at gmail.com
Fri Jan 21 11:53:23 EST 2011


Note that this is a local reference not a local copy. Reusing a local
reference eliminates one (slower) instance variable lookup at runtime.

On Jan 21, 2011 8:39 AM, "Navin Jha" <navin.jha at fxall.com> wrote:

 I was looking at the CopyOnWriteArrayList.java source code and I see that
in all the modification methods a copy of the lock is made first, something
like:



public E set(int index, E element) {

                final ReentrantLock lock = this.lock;

                lock.lock();

…………………………….. // rest of the method



I understand that making local copies of object variables would reduce
contention but is that the reason for doing this in this case or something
else?



Regards,

Navin



_______________________________________________
Concurrency-interest mailing list
Concurrency-interest at cs.oswego.edu
http://cs.oswego.edu/mailman/listinfo/concurrency-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20110121/b9ff0755/attachment.html>


More information about the Concurrency-interest mailing list