JavaMemoryModel: Some odds and ends

From: Bill Pugh (
Date: Sun Oct 24 1999 - 10:32:05 EDT

When thread T1 starts thread T2, T2 starts with the overwritten and
previous information of T1.

When a thread T1 terminates, it does a release to a special thread
termination object. Whenever another thread T2 detects that T1 has
terminated, T2 does an acquire on the thread termination object.

        T2 detects that T1 has terminated by doing a join, invoking isAlive on T1, or
        if T2 is a VM termination thread (the ability to register tasks to be run
on VM
        termination was added in JDK 1.3) and T1 is a non-daemon thread that
        before the VM decided to terminate.

Sleep requires no memory barriers nor does it require that registers be
There is lots of code that has a loop with a sleep statement in it, and
expects to see changes
by other threads when it wakes up from sleep. Under my proposed model, this
code is badly broken
and will not work.

As an optional extensions, we could say that whenever thread T1 interrupts
T2, that it is treated as a release by T1 on the interrupt, when is
acquired by T2 when it detects the interrupt (e.g., by throwing an
InterruptedException). The basic idea is that whenever thread T1 uses a
mechanism that is clearly intended for inter-thread communication to
communicate with thread T2, it should be treated as a release by T1 that is
acquired by T2.

When a thread invokes wait(), it gives up locks, do it does a release. When
a thread wakes up after a wait(), it reacquires locks, so it does an acquire.

For reads of longs and doubles, if |allWrites(v) - overwritten_T1(v)| > 1,
then the read can return an arbitrary value of that type (i.e.,
reads/writes of longs and doubles are not atomic).

JavaMemoryModel mailing list -

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