Re: JavaMemoryModel: The Optimistic Read Idiom and the new Java Memory Model

From: Bill Pugh (
Date: Tue Oct 31 2000 - 00:13:26 EST

The "Optimistic Read Idiom" is incorrectly synchronized code.

The "happens-before" relationships induced by by accesses to volatile
variables and locks do not impose an ordering constraint between all
conflicting accesses.

I see no need to support the "Optimistic Read Idiom", any more than I
see a need to support "Double-checked locking".

Under my semantics, as Rob observed, the write to a and b can be done
presciently, which means that the "Optimistic Read Idiom" will not

Rob's trick, of inserting a read of v, would work under my existing
semantics. But I've already been considering ways of allowing
prescient writes to be moved ahead of volatile reads and locks who's
matching write/unlock is the same thread.

My interest is in having a simple model that is easy to explain. I
don't want the system to support any ugly hacks that would be
erroneously used 95% of the time.

JavaMemoryModel mailing list -

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