Bill Pugh wrote:
> >>For example, consider:
> >>
> >>Initially, x = y = 0
> >>
> >>Thread 1:
> >>   if x != 0
> >>     y = 1
> >>
> >>Thread 2:
> >>   if y != 0
> >>     x = 1
> >>
> >>You must be careful to not allow this program to result in 
> x = 1 and y 
> >>= 1.
> >>
> >>     Bill
> >>-------------------------------
> >>JavaMemoryModel mailing list - 
> >>http://www.cs.umd.edu/~pugh/java/memoryModel
> >
> >
> >Why not?  No, I'm not arguing that this should be allowed.
> >I just want to hear your reasons why This Is Bad.
> >
> >Cliff
> 
> This program is correctly synchronized and therefore must execute 
> according to sequentially consistent semantics.
> 
> The basic definition of "correctly synchronized" is, for all 
> sequentially consistent executions of the program, an ordering 
> consistent exists between any two conflicting accesses to a variable.
> 
> There is only one sequentially consistent execution of this program, 
> in which each thread reads one variable and doesn't write any. So 
> there are no conflicting accesses, and the only execution allowed is 
> the sequentially consistent one.
> 
> 	Bill
Perhaps this is a silly question, but is it a foregone conclusion that
all multi-threaded but unsynchronized Java programs are sequentially
consistent?  That seems to be implied by the above analysis.
- Roly
Roly Perera
Ergnosis Ltd
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:35 EDT