RE: JavaMemoryModel: correct synchronization

From: Eliot Moss (moss@cs.umass.edu)
Date: Mon Feb 23 2004 - 06:51:35 EST


>>>>> "David" == David Holmes <dholmes@dltech.com.au> writes:

>> On Feb 20, 2004, at 5:16 PM, Adam Welc wrote:
>> >
>> >
>> > Is the following program correctly synchronized?
>> >
>> >
>> > public static boolean w = false;
>> > public static boolean v = false;
>> >
>> > T1 T2
>> > w=true; while(true) {
>> > synchronized(M) { synchronized(M) {
>> > v =true; if (v) break;
>> > } }
>> > }
>> > boolean tmp=w;
>>

David Holmes said he feels that this code fragment breaks the rules of
writing correctlty synchronized code ....

I ask: Is this not, in effect, barrier synchronization. a tried and true
and widely used technique?

-- Eliot Moss
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



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