[concurrency-interest] Double Checked Locking in OpenJDK

Yuval Shavit yshavit at akiban.com
Mon Aug 13 18:02:37 EDT 2012

On Mon, Aug 13, 2012 at 5:46 PM, Wolfgang Baltes <
wolfgang.baltes at laposte.net> wrote:

> There are different ways to accomplish this, the most obvious ones being
> to declare a fields final or volatile.

I would say that the most obvious way is to use a safe publication
mechanism, such as any of the threadsafe collections, which establishes a
happens-before between the put and subsequent get. If your object's fields
don't change after the constructor, and thread A gives the object to thread
B via a threadsafe collection, then it doesn't matter whether the object's
fields are final/volatile -- the HB barrier is provided by the collection.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20120813/ccb2ac53/attachment-0001.html>

More information about the Concurrency-interest mailing list