On 28/09/2009, Stephen Colebourne <scolebou...@btopenworld.com> wrote:
> sebb wrote:
>
> > Where is that described? The first reference I found says that the
> > local variable is a performance optimisation; it's the volatile
> > keyword that makes it thread-safe:
> >
> >
> http://technology.amis.nl/blog/4384/the-double-checked-locking-confusion
> > also
> >
> http://jeremymanson.blogspot.com/2008/05/double-checked-locking.html
> >
> > But of course these could be wrong...
> >
>
> http://java.sun.com/developer/technicalArticles/Interviews/bloch_effective_08_qa.html
>
>  "The idiom is very fast but also complicated and delicate, so don't be
> tempted to modify it in any way"
>

That does not necessarily mean that the version without the temporary
variable is wrong.

As I see it, the fact that the variable is volatile is enough to
ensure as-sequential operation, because the write of the volatile
variable happens-before the read.

>  Stephen
>
> ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
>  For additional commands, e-mail: dev-h...@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to