On Mon, Jun 15, 2009 at 4:39 PM, Caldarale, Charles
R<chuck.caldar...@unisys.com> wrote:
>> From: Sid Sidney [mailto:pvcsv...@yahoo.com]
>> Subject: Re: using static helper classes within servlets
>
> On a modern JVM, the synchronized block around the retrieval of the reference 
> will not cost much.  Static initialization will of course avoid that, if it's 
> >feasible to instantiate the objects at class load time.  Using the 
> double-checked locking mechanism is still considered poor practice, since 
> it's very easy >to get wrong.  The initialize-on-demand holder class is 
> probably the best way to avoid premature object instantiation, and is 
> guaranteed to work; this >article contains the details:

Hi Chuck,

Even I mostly agree with everything you say in advance, I must oppose
this time, that DLC is explicitly recommended in the item 71, "Use
lazy initialization judiciously" in effective java second edition by
Joshua Bloch.

http://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683/ref=sr_1_1?ie=UTF8&s=books&qid=1245080229&sr=8-1

However in concurrency in practice, which he co-authored at about the
same time, it's considered harmful.
Well, you never know, what an author has on its mind, but the 'not so
new anymore' volatile semantics actually guarantee DLC to work :-)

regards
Leon

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

Reply via email to