You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christopher Schultz <ch...@christopherschultz.net> on 2009/06/15 18:32:24 UTC

Re: [OT] using static helper classes within servlets

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David,

On 6/14/2009 5:43 PM, David Blevins wrote:
> Regardless of that choice we
> will still handle sychronization of instantiation, so
> double-check-locking or other things will not be necessary.

NB: DCL does not work in Java. Period.

http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html

There are cases where you /can/ make it work, but let's face it: most
programmers simple cannot be trusted to do it properly. Also, the
techniques are very sensitive to JVM level, etc. so you'd need to have a
different implementation depending on which JVM you were running. Yuk.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAko2d5gACgkQ9CaO5/Lv0PAUmACgqYFB8fvkL0fts8Ot/KAOnwL9
mWYAoKBFHEGfi0oWk1WXtAdcVW69G1hD
=I+hs
-----END PGP SIGNATURE-----

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


Re: [OT] using static helper classes within servlets

Posted by David Blevins <da...@visi.com>.
On Jun 15, 2009, at 9:32 AM, Christopher Schultz wrote:

> On 6/14/2009 5:43 PM, David Blevins wrote:
>> Regardless of that choice we
>> will still handle sychronization of instantiation, so
>> double-check-locking or other things will not be necessary.
>
> NB: DCL does not work in Java. Period.
>
> http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html
>
> There are cases where you /can/ make it work, but let's face it: most
> programmers simple cannot be trusted to do it properly. Also, the
> techniques are very sensitive to JVM level, etc. so you'd need to  
> have a
> different implementation depending on which JVM you were running. Yuk.

Chris, I was referring to the EJB 3.1 Singleton bean type which would  
free him up from having to write that complicated code you mention.

-David


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


RE: [OT] using static helper classes within servlets

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Christopher Schultz [mailto:chris@christopherschultz.net]
> Subject: Re: [OT] using static helper classes within servlets
> 
> NB: DCL does not work in Java. Period.

While that statement was true for 1.4 and prior JVMs, 1.5 actually made DCL work.

> http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html

Note that the majority of the above was written prior to the development of JSR 133, let alone its implementation; my reading of JSR 133 indicates that the volatile keyword is no longer required, due to the requirement of flushing any internally cached values at the entrance to a synchronized block.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


Re: [OT] using static helper classes within servlets

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tim,

On 6/15/2009 12:43 PM, Tim Funk wrote:
> correction: The double checked idiom was "fixed" in java5. The variable
> which is checked needs to be declared as volatile. The link states that
> at the bottom.

...which is why I said:

>> There are cases where you /can/ make it work, but let's face it: most
>> programmers simple cannot be trusted to do it properly. Also, the
>> techniques are very sensitive to JVM level, etc. so you'd need to have a
>> different implementation depending on which JVM you were running. Yuk.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAko2yWoACgkQ9CaO5/Lv0PDHOgCfarmCJhzzjKfeC7tF4tTT2eF6
9DoAoJP2gROiP3B+hvnRseGnttrPfVcP
=XWKy
-----END PGP SIGNATURE-----

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


Re: [OT] using static helper classes within servlets

Posted by Tim Funk <fu...@apache.org>.
correction: The double checked idiom was "fixed" in java5. The variable 
which is checked needs to be declared as volatile. The link states that 
at the bottom.

-Tim

Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> David,
>
> On 6/14/2009 5:43 PM, David Blevins wrote:
>   
>> Regardless of that choice we
>> will still handle sychronization of instantiation, so
>> double-check-locking or other things will not be necessary.
>>     
>
> NB: DCL does not work in Java. Period.
>
> http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html
>
> There are cases where you /can/ make it work, but let's face it: most
> programmers simple cannot be trusted to do it properly. Also, the
> techniques are very sensitive to JVM level, etc. so you'd need to have a
> different implementation depending on which JVM you were running. Yuk.
>   


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