[concurrency-interest] Double Checked Locking in OpenJDK
joe.bowbeer at gmail.com
Sun Aug 12 21:46:35 EDT 2012
On Sun, Aug 12, 2012 at 6:09 PM, R Samuel Klatchko wrote:
> Also, wouldn't this be a benign data race as wanting to
> call FileSystems.getDefault().getPath only once is for performance and not
> for correctness.
In general, Double-checked locking is broken because observing ref != null
in one thread (without synchronization) does not ensure that the internal
state of the referenced object has been safely published to that thread.
In this specific case, however, I just noticed that the Path javadoc
requires thread safety in addition to immutability:
"Implementations of this interface are immutable and safe for use by
multiple concurrent threads."
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Concurrency-interest