[concurrency-interest] Significance of volatile for Objects

Dhanji R. Prasanna dhanji at gmail.com
Fri Mar 7 07:18:49 EST 2008

On Fri, Mar 7, 2008 at 10:19 PM, Pavitar Singh <pavitar at pramati.com> wrote:

> Hi,
> Thanks for your explanations.
> When i read JMM about Happens Before Relationships:
> It says:
> A write to a volatile field happens before every subsequent read of that
> volatile.
> But then doing operation on HashMap like put. It doesnt mean write to the
> volatile field.Siimilarly a get shouldnt mean read from volatile.Is it
> correct or i am missing something here.

Correct, the volatile field holds a reference to a hashmap, but reads and
writes to the hashmap itself are subject to its own synchronization
concerns. Hence, synchronized and ConcurrentHashMap.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20080307/fa21043d/attachment.html 

More information about the Concurrency-interest mailing list