At 1:53 PM -0700 5/26/00, Gregory Thain wrote:
>I believe (please correct me if I'm wrong) that this case simply
>demonstrates a bug in the Symantec code generator. A program should
>never see an unconstructed (or partially constructed) object (outside
>the constructors, of course).
Assuming that the allocation routine initializes the fields of the
singleton to zero, it is perfectly legal under the existing
specification. Note that it should be impossible for the thread
creating the object to see an incompletely initialized object. Only
another thread can see the incompletely initialized object.
The rational for allowing this is that on some shared memory
multiprocessors, the JVM would need to perform synchronization
But yes, you are right to be worried by this. This is why the double
check idiom should not be used.
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:26 EDT