[concurrency-interest] readValueUnderLock in ConcurrentHashMap

Pavitar Singh pavitar at pramati.com
Tue Apr 8 10:57:07 EDT 2008


Hi All,

I didnt understand why do we need readUnderLock during get in
ConcurrentHashMap.

"This is possible only if a compiler happens to reorder a HashEntry
initialization with its table assignment, which is legal under memory
model          but is not known to ever occur."  from the javadoc.

Does that mean :
in put method .

tab[index] will have a HashEntry , but not yet initialized (constructor
invoked)

if this is the case then how HashEntry hash and key will be visible in:
get method.
if (e.hash == hash && key.equals(e.key))

Regards
Pavitar




More information about the Concurrency-interest mailing list