RE: JavaMemoryModel: Re: JMM problems with latch or copy-on-write ?

From: Boehm, Hans (hans_boehm@hp.com)
Date: Fri Mar 30 2001 - 13:28:32 EST


> From: Jeff Bogda [mailto:bogda@cs.ucsb.edu]

> One may argue that this synchronization is not useless
> because it makes the
> value "true" for "initialized" visible to thread 2. However,
> I agree with
> Jeremy (although I am not sure where in his paper he states
> this) and feel
> that these synchronized blocks (like all empty synchronized
> blocks) are
> useless.

I think the last parenthetical comment is an overgeneralization. Consider

Thread 1:

synchronized(global1) {
  thread2.start();
  set up some global shared state S;
}
read S;

Thread 2:

  synchronized(global1){}
  read S;

The empty synchronized block is used to wait for the initialization of S.
Removing it is clearly incorrect.

This is probably uncommon in Java, but I believe it's correct under all
current proposals. I've used it a few times with a pthreads like thread
model, without s separate start operation.

Hans

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



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