[concurrency-interest] Unsafe publication of new objectsquestion
davidcholmes at aapt.net.au
Fri Nov 12 22:12:47 EST 2010
Justin T. Sampson writes:
> On Fri, Nov 12, 2010 at 2:16 PM, David Holmes <davidcholmes at aapt.net.au>
>> Andrew Trick writes:
>> > The JVM needs an effective store-store memory barrier between all
>> > stores that initialize a new object and any store that may publish a
>> > pointer to it. Not easy to do efficiently on all architectures.
>> The JVM would need this if it were to guarantee safe-publication, but it
>> doesn't guarantee that.
> It does for final fields, right? Or is that a different concept?
There are additional guarantees regarding the initialization of final
fields. I suggest reading Section 17.5 of the Java Language Specification
for the details, but for a simple formulation see the "Final Fields" section
of the JMM Cookbook:
More information about the Concurrency-interest