Christopher Cobb wrote:
> Unfortunately, these approaches do not address multithreading or serialization
>issues.
>
> See 'Effective Java' by Joshua Bloch, or
>http://www.javaworld.com/javaworld/javaqa/2002-04/01-qa-0412-doublelock.html.
For our project, we use the following pattern for our singletons which
avoids the double-locking problem:
public class Foo {
private static class SingletonInstance {
private static final Foo instance = new Foo();
}
public static Foo getInstance() {
return SingletonInstance.instance;
}
}
Class loading and field initialisation semantics guarantee that the
instance will be created before any thread accesses the field via
Foo.getInstance().
Ciao,
Gordon
--
Gordon Tyler
Software Developer, R&D
Sitraka -- Performance is Mission Critical
_______________________________________________
Eap-features mailing list
[EMAIL PROTECTED]
http://lists.jetbrains.com/mailman/listinfo/eap-features