[concurrency-interest] Stupid Question

Michael Kuhlmann concurrency at kuli.org
Wed Feb 13 08:09:59 EST 2013

Am 13.02.2013 13:10, schrieb Markus Krainz:
> Hi,
> I have read that blog post some time ago. It uses the SwitchPoint class
> to optimize the access.
> I am wondering, could this be more efficient than the double-checked
> locking idiom used e.g. for lazy initialization?

This isn't directly comparable. The mentioned code is just too
complicated for sa simply lazy initialization. Better just use an own
static container class for lazy initialization as in

But top answer your question, yes. In fact, double checked locking only
works for volatile fields or immutable objects with only final fields.
In either case, JIT can't optimize the read access away since it's not a
static final declaration.


More information about the Concurrency-interest mailing list