[concurrency-interest] readValueUnderLock in ConcurrentHashMap

Jason T. Greene jason.greene at redhat.com
Wed Apr 9 10:23:30 EDT 2008


Pavitar Singh wrote:
> "Because they are final. Final fields are guaranteed to be visible as
> long as the object is not published before the constructor has
> completed."
> 
> But object has been published even before constructor is completed. As
> Threads can see it by going through table(tab)?

This is referring to the order as specified in the code (i.e. the 
guarantee does not apply if the constructor leaks "this"). Basically, a 
write to a final field in a constructor is not allowed to be re-orderd 
to occur after a write of the containing object that is after the 
constructor.

-- 
Jason T. Greene
JBoss, a division of Red Hat


More information about the Concurrency-interest mailing list