Re: JavaMemoryModel: Weak fairness in the Java memory model

From: Bill Pugh (
Date: Mon Apr 12 2004 - 23:05:47 EDT

On Apr 12, 2004, at 7:17 PM, David Holmes wrote:

> Bill Pugh wrote:
>> However, it does make it pretty difficult for the compiler
>> to do some undesirable transformations, such as
>> hoisting the volatile read out of the loop.
> Surely these are the sorts of optimisations that could never be made on
> volatiles - memory visibility aside - the compiler must always re-read
> a
> volatile as per the code in the program. ???
> David Holmes

The problem is how do you state this in some way that is formally sound
and has teeth.

You could say that the loop never terminated because it performed an
infinite number
of volatile reads directly from main memory, all of which occurred
before the volatile write
by thread 2.

If this makes your brain hurt, you aren't alone. The practical impact
of this rule is that reads
and writes must go directly to main memory.


JavaMemoryModel mailing list -

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