[concurrency-interest] ConcurrentHashmap.putIfAbsent oddities

peter royal peter.royal at pobox.com
Fri Dec 8 17:34:19 EST 2006


On Dec 8, 2006, at 1:50 PM, Tim Peierls wrote:
> map.putIfAbsent uses identity semantics and map.get uses equals/ 
> hashCode semantics.

Where is this documented?

Looking at http://java.sun.com/j2se/1.5.0/docs/api/java/util/ 
concurrent/ConcurrentHashMap.html#get(java.lang.Object) and http:// 
java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ 
ConcurrentHashMap.html#putIfAbsent(K,%20V)

The javadocs for putIfAbsent say that its equivalent to a ! 
containsKey, and containsKey says it uses equals() to determine  
existence.

the JCIP book also does not mention anything about ConcurrentHashMap  
using identity semantics.

-pete

-- 
(peter.royal|osi)@pobox.com - http://fotap.org/~osi

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2454 bytes
Desc: not available
Url : /pipermail/attachments/20061208/a4d6439c/attachment.bin 


More information about the Concurrency-interest mailing list