Re: JavaMemoryModel: Question about implementation of java.util.concurrent.ConcurrentHashMap

From: Jeremy Manson (jmanson@cs.umd.edu)
Date: Thu Nov 13 2003 - 15:17:39 EST


> Bill (and others),
>
> You wrote:
>
> "In general, a JVM is not allowed to reorder a volatile write with any
> > preceding accesses to shared memory."
>
> Although I found reference to this in the JMM archives, I could not
> find this statement in the community review 2 JMM document.
>
> Is it unintentionally missing from the document?

It isn't a hard and fast rule. It is simply implied by the fact that all
the actions before a volatile write have to be visible to any actions
following a subsequent volatile read on the same variable; this is implied
by the happens-before rules.

So, for example, you can do the reordering if no other thread ever reads
that volatile. Or if they read the volatile, but never see any results of
the access being reordered.

                                        Jeremy
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:53 EDT