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

Vitaly Davidovich vitalyd at gmail.com
Fri Jan 21 13:56:46 EST 2011


Missed rest of the group.
On Jan 21, 2011 1:13 PM, "Vitaly Davidovich" <vitalyd at gmail.com> wrote:
> I believe this is Doug's optimization to work around hotspot not
eliminating
> repeated final instance field reads across lock() calls.
> On Jan 21, 2011 12:38 PM, "Navin Jha" <navin.jha at fxall.com> wrote:
>> Thanks. What about using final keyword inside the method for the local
> reference, what is the reason for that?
>>
>> From: Joe Bowbeer [mailto:joe.bowbeer at gmail.com]
>> Sent: Friday, January 21, 2011 11:53 AM
>> To: Navin Jha
>> Cc: concurrency-interest at cs.oswego.edu
>> Subject: Re: [concurrency-interest] Making copy of a reference to
> ReentrantLock
>>
>>
>> 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<mailto:
> 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<mailto:
> 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/13ed9b6b/attachment-0001.html>


More information about the Concurrency-interest mailing list