JavaMemoryModel: Use-case for strong volatile interpretation

From: Bill Pugh (
Date: Mon Mar 29 2004 - 17:36:10 EST

OK, consider the following situation.

You have some sort of simulation/relaxation based algorithm,
with a shared data structure, multiple threads that are updating
the data structure and multiple threads reading the data structure.

The updating threads do not have to synchronize among themselves,
since they are updating disjoint sections of the shared data structure.

The reading threads don't need to see any particular iteration of the
update, or the most recent update. They just want to see data that isn't
too far out of date.

With the strong interpretation, it suffices to have a shared volatile,
each updating thread periodically write to the volatile, and each
thread periodically read the volatile.

With the weak interpretation, this works if there is only one updating
thread. If there is more than one updating thread, the updating threads
need to perform a CAS on the volatile rather than a write.

The thing that bothers me the most about this scenario is that there is
a synchronization idiom that works perfectly fine when you have one
thread that breaks down if you have two updating threads.

I talked with Doug and he agreed that this use case is at least somewhat

Given this use case, and the fact that all of the official JSR-133
have clearly stated the strong interpretation, I am planning to stick
with the
strong interpretation, even though this might cause implementation
issues for future DSM implementations of Java (there are plenty of other
issues that would need to be dealt with for a DSM implementation of Java
anyway, such as final fields).


JavaMemoryModel mailing list -

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