Thomas Wang wrote:
> Initially, x = y = v = 0. v is a volatile variable.
>
> Thread 1:
> r1 = x
> v = 0
> y = 1
>
> Thread 2:
> r3 = y
> v = 0
> x = 1
>
> Is the behavior r1 == r3 == 1 possible?
By my understanding - yes. The write to the volatile is a "release" and
operations can be moved before a "release" under the "roach motel"
semantics. Hence the code can be reordered as:
Thread 1:
y = 1
r1 = x
v = 0
Thread 2:
x = 1
r3 = y
v = 0
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:00 EDT