Re: JavaMemoryModel: Semantics of volatile

From: Tom May (tom@go2net.com)
Date: Wed Mar 22 2000 - 14:16:42 EST


Bill Pugh <pugh@cs.umd.edu> writes:

> V1
> // Does a volatile read always have to be done from main memory?
> Initially:
> volatile boolean a = false;
>
> Thread 1:
> a = true;
>
> Thread 2:
> while (!a);
>
> Question: Is it possible that thread 2 will never terminate?

I haven't been following all of this, but there seem to be two reasons
why thread 2 might not terminate. This code will not distinguish
between the two.

1. Thread 1 doesn't write to main memory.
2. Thread 2 doesn't read from main memory.

Tom.
-------------------------------
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