On Wed, Jun 6, 2012 at 1:51 PM, Cezary Biernacki <[email protected]> wrote:
> On 06 June 2012 21:20:02 +0200 Howard Lewis Ship <[email protected]> wrote:
>> http://tapestryjava.blogspot.com/2012/06/synchronized-considered-harmful.html
> I am curious is there a reason to not use 'double-checked locking' pattern?
> I know that it was broken in Java 1.4 and earlier, but Java Memory Model was
> changed (JSR-133) for Java 5.0 to accommodate that pattern. Of course, you
> need to use 'volatile' field, but AFAIK it does not impose any significant
> penalty (especially for reads) on most platforms including most x86 and
> emt64. Am I missing something?

Same question, and I think there's still more places in T5 code that
could simply return the object if it exists before synchronizing or
obtaining locks if the field was volatile. Specifically, even before
the try block, could you not do:
if (messages != null) return messages;

Or, depending on where it's cleaned up:
Messages messages = this.messages;
if (messages != null) return messages;

?

Kalle

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to