Re: JavaMemoryModel: Problem on single processor

From: David Holmes (
Date: Thu May 25 2000 - 18:24:41 EDT

> This does not work. According to both the existing specification, and
> proposed new specifications, the write to singletons[i] can be moved
> inside the synchronized block.

It can? I am surprised in the sense that I view memory barriers as implicit
code motion barriers and so, unless the compiler/JIT can be 100% certain
that what it is doing is correct it should not move code across
synchronization points.

However, Bill is quite right that the spec does not actually say this.

If this were rewritten in C with POSIX Mutexes would that still be the case?

In any case - yes the double-check is broken - end of story. I was simply
illustrating a commonly suggested non-solution.


JavaMemoryModel mailing list -

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