RE: JavaMemoryModel: Semantics musings

From: David Holmes (dholmes@dltech.com.au)
Date: Tue Sep 25 2001 - 21:36:15 EDT


> >> From: owner-javamemorymodel@cs.umd.edu
> >> [mailto:owner-javamemorymodel@cs.umd.edu]On Behalf Of Bill Pugh
> >>
> >> This program is correctly synchronized and therefore must execute
> >> according to sequentially consistent semantics.
> >
> > David Holmes wrote:
> >Okay I'll bite. How can the program be correctly synchronized when it
> >contains no synchronization code?
>
> "Correctly synchronized" == "contains no data races"
>
> A single threaded program is always correctly synchronized.
>
> Two threads that run in parallel but touch no data in common are
> correctly synchronized, no matter what synchronization they contain.

Sure. But here's the example that was being discussed:

>>For example, consider:
>>
>>Initially, x = y = 0
>>
>>Thread 1:
>> if x != 0
>> y = 1
>>
>>Thread 2:
>> if y != 0
>> x = 1

I see two threads, each accessing data modified by the other. That's a data
race. ;-)

David Holmes

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