RE: JavaMemoryModel: Semantics musings

From: Bill Pugh (
Date: Tue Sep 25 2001 - 21:23:42 EDT

At 9:49 AM +1000 9/26/01, David Holmes wrote:
> > -----Original Message-----
>> From:
>> []On Behalf Of Bill Pugh
>> 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.
>Okay I'll bite. How can the program be correctly synchronized when it
>contains no synchronization code? If it did contain synchronization code
>then any execution produced by the compiler/runtime/hardware must be
>consistent with a sequentially consistent execution. As it stands, unless we
>have decided for sequentially consistent semantics as a baseline for
>unsynchronized code, then the compiler/runtime/hw can do whatever it likes
>as long as the actions in each thread are consistent with the code in that

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

It is very easy to have a multithreaded program with no
synchronization that "contains data races"/"is incorrectly
synchronized". For example:

Initially: x = 0

Thread 1:
x = 1

Thread 2:
r1 = x

JavaMemoryModel mailing list -

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