[concurrency-interest] Synchronizing on ReservationNode in ConcurrentHashMap.computeIfAbsent

Jason Tedor jason at tedor.me
Fri Apr 15 07:53:23 EDT 2016


This was discussed previously:
http://cs.oswego.edu/pipermail/concurrency-interest/2016-January/014857.html

On Fri, Apr 15, 2016 at 2:22 AM Unmesh Joshi <unmeshjoshi at gmail.com> wrote:

> Hi,
>
>
> I was browsing through the code of ConcurrentHashMap.computeIfAbsent and on line 1655, I see synchronization as following..
>
> (http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/util/concurrent/ConcurrentHashMap.java?av=f)
>
>
>   Node <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/util/concurrent/ConcurrentHashMap.java#ConcurrentHashMap.Node><K,V> r = new ReservationNode <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/util/concurrent/ConcurrentHashMap.java#ConcurrentHashMap.ReservationNode><K,V>();
>
> synchronized (r)
>
>
> What is the significance of synchronizing on new object?
>
>
> Thanks,
>
> Unmesh
>
>
> _______________________________________________
> 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/20160415/27fc7e09/attachment.html>


More information about the Concurrency-interest mailing list