JavaMemoryModel: Correction to litmus test V4

From: Bill Pugh (pugh@cs.umd.edu)
Date: Wed Mar 22 2000 - 14:02:42 EST


The field q should not have been marked volatile.
I've also changed the loading of q in thread 2 to make the point
more obvious.

V4
// Does volatile guarantee fresh values for direct contents of referenced
// object even if referenced through a different name?
Initially:
volatile Node p;
Node q; // Not volatile

Thread 1:
Node tmp1 = new Node();
q = tmp1;
tmp1.x = 1;
p = tmp1;

Thread 2:
Node tmp_q = q;
Node tmp_p = p;
int tmp3 = tmp_q.x;

Question: Is it possible that thread 2 gets a value of 0 in tmp3?
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



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