On Wed, Jun 6, 2012 at 1:51 PM, Cezary Biernacki <cezary...@gmail.com> wrote:
> On 06 June 2012 21:20:02 +0200 Howard Lewis Ship <hls...@gmail.com> 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?

double checked lock works in some cases.

You can even omit synchronized and volatile IFF:
- only a single shared field is updated
- it is ok for a race condition to exist that would create the value
on multiple threads
- (I learned this by getting schooled on the subject by Rich Hickey)

There are many things in Tapestry that don't fit this model.
Sometimes the value being lazily created is so expensive, it would be
invalid to allow multiple threads to create it.  In other cases, more
than one shared field is updated.

>
> Cezary
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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

Reply via email to