Re: JavaMemoryModel: Executions I find profoundly troubling

From: Bill Pugh (pugh@cs.umd.edu)
Date: Mon Jul 28 2003 - 16:33:34 EDT


At 12:30 PM -0700 7/28/03, Paul Loewenstein wrote:
>Surely, you can't make multiple writes to a shared variable even if
>the writes have the same value, because another thread could write a
>different value between the multiple writes, making the
>multiple-write visible.
>
>Paul

No, I think this is OK. For example, consider:

Initially, x = 0

Thread 1 Thread 2:
x = 1 r1 = x
                x = 2
                r2 = x
                r3 = x

The legal behaviors of this program are that r1 must be either 0 or
1, and r2 and r3 can be either 1 or 2. Any of those 8 possibilities
are legal.

You have to allow this kind of behavior, due to issues with aliasing.

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



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