RE: JavaMemoryModel: Legality of native code changing final field s

From: np087@mdx.ac.uk
Date: Wed Jun 13 2001 - 13:32:14 EDT


On Mon, 11 Jun 2001, Bill Pugh wrote:

> This is similar to what happens when a constructor makes an object
> visible to other threads before the object is completely constructed.
> I don't recommend it, but the spec has to specify the semantics of
> doing so.

What's going to happen with this?
JLS 8.8.3 seems to suggest it is disallowed: "There is no practical need
for a constructor to be synchronized, because it would lock the object
under construction, which is normally not made available to other threads
until all constructors for the object have completed their work."

Are constructors going to be allowed to be synchronized in the future?
This makes it a bit clunky... deciding whether or not an object will be
shared *for the whole class*. I think I'd prefer guaranteeing the
reference's unavailability until the contructor had finished. I know it
breaks some JITCs but something's got to give.

Cheers,
Nigel.

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



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