Re: JavaMemoryModel: Dropping coherence is more complicated than we thought

From: Bill Pugh (pugh@cs.umd.edu)
Date: Sun Nov 07 1999 - 22:10:02 EST


At 7:54 PM -0500 11/7/99, Doug Lea wrote:
>The value of an assignment statement is
>the value of its right hand side, ...
>
>-Doug

The better way to have written the code would be:

int v;
int getValue() {
   int tmp = v;
   if (tmp != 0)
     v = tmp = computeValue();
   return tmp;
   }

As Doug mentioned, having a field in the middle of an assignment chain
could give very unexpected results for unsynchronized code.

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