RE: JavaMemoryModel: Use-case for strong volatile interpretation

From: David Holmes (dholmes@dltech.com.au)
Date: Mon Mar 29 2004 - 19:36:27 EST


Bill Pugh wrote:
> With the strong interpretation, it suffices to have a shared volatile,
> and each updating thread periodically write to the volatile, and each
> reading 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.

When you say CAS do you mean that there must be a volatile read followed by
a volatile write? With CAS the write is conditional so I'm not clear what
aspect of the CAS make this work correctly.

> 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
> updating thread that breaks down if you have two updating threads.

I agree this is a "Bad Thing". The distinction is far too subtle.

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:02 EDT