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

Unmesh Joshi unmeshjoshi at gmail.com
Fri Apr 15 02:09:08 EDT 2016


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20160415/da14a84f/attachment.html>


More information about the Concurrency-interest mailing list