RE: JavaMemoryModel: Sticking with happens-before

From: David Holmes (dholmes@dltech.com.au)
Date: Fri Mar 26 2004 - 20:00:33 EST


Sylvia Else wrote:
> There have been concerns expressed here, and in associated
> documents, that people will get confused when they end up making
> statements like "An event happens-before another event that it happens
> before." However, I think that in that case, the confusion exists in the
> mind of the speaker even before the sentence is uttered.

I disagree. The problem is that "happens before" has too many contexts. When
we write code we can write statement A before statement B and the regular
language rules tell us that statement A is executed ie "happens before"
statement B. I can run a program and thread 1 can do action A and then
sometime later thread 2 does action B, so at runtime A "happens before" B.
But neither of these are the same as the happens-before relationship defined
in the JMM (in the event case they might be, but need not).

It sounds silly to say "when start() is invoked on a thread t then it
happens-before the execution of the thread's run method". Well Duh! How
could the thread run *before* start() is called in it! Similarly with a
successful join - if the thread terminated *after* join returned
successfully then join() was lying.

Sometimes there are obvious temporal relationships between events that need
not translate into synchronization relationships. So given that it is
"obvious" that event A must have occurred before event B, we need a better
way to describe the synchronization action, if any, that implies.

I dislike "synchronizes to/from" etc - I agree with Victor they these sound
unnatural (I'm not even sure they are grammatically correct). "synchronizes
with" captures things nicely for me - it how this stuff is normally
explained:"if two threads want to access shared data reliably then they must
synchronize". I disagree that there is necessarily an implied symmetry with
"synchronizes with".

I think we need a new term that doesn't have an existing common
interpretation in this context. Sorry I haven't yet thought of one.

That said I would still use "roach motel" to explain the basic principles.

David Holmes

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



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