Hi David,

you are right, it's a vice implement singletons that way.
Add this on my my todo-list (hope to get rid of this before 1.0).

regards,
Armin

----- Original Message -----
From: "David McReynolds" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, March 03, 2003 5:55 AM
Subject: multithreading


> Sorry if this has been asked before. I can't seem to get to the
archives.
>
> In the source code for OJB I have noticed several uses of the
Singleton
> pattern. Mostly, the code is of then form,
>
> <SingletonName> {
>
>     private static <SingletonName> _instance;
>
>     <SingletonName> getInstance() {
>         if(_instance == null) {
>             _instance = getNewInstance();
>         }
>
>         return _instance;
> }
>
> I am puzzled by this idiom because it has been documented as "broken"
for
> the Java memory model with respect to multi-thread applications.
>
> http://www.javaworld.com/javaworld/javatips/jw-javatip67-p2.html
states,
> "Using lazy instantiation for a concrete Singleton is not only
unnecessary
> in Java, it's downright dangerous in the context of multithreaded
> applications."
>
> Ref:
> http://www.javaworld.com/javaworld/javatips/jw-javatip67.html?
> http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double.html
> http://www.javaworld.com/javaworld/jw-05-2001/jw-0525-double.html
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to