Is the temporary variable "result" needed?
Or maybe I'm missing some subtlety here ?
In which case it should be documented in a comment please.
<snip/>
According to Bloch's book the temporary variable is indeed a performance
optimization. It prevents that the volatile field is read twice in the
common case that the object has already been initialized.
Its not about performance. Without the local variable, the pattern is
unsafe concurrently. The pattern must be followed exactly (including the
double assign) in order for the locking to be concurrent-safe.
Stephen
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org