[concurrency-interest] concurrency puzzle

David Holmes dcholmes at optusnet.com.au
Sun Sep 10 20:11:45 EDT 2006


I wrote:
> Ummm if the assignment occurs in the print method then the subsequent
> println must print 42 regardless because the assignment occurred
> in the same thread.

As Jeremy has been pointing out you need to see how multiple threads come to
access the instance of the class. What I wrote above is incorrect if the
instance was unsafely published because the write in the constructor due to
the initialization statement could "appear" after the assignment within the
print method.

Sorry for adding to the confusion.

Cheers,
David Holmes



More information about the Concurrency-interest mailing list