Singleton pattern 2005-10-04 - By SUBSCRIBE EJB-INTEREST anonymous
Back Hi, Thank for both of your answers. The IBM article was very helpful. I am unable to forgo synchronization and use a static field as below as I am throwing exception from the getInstance() method.
private static Singleton singleton = new Singleton();
The IBM article recommends not to use double-checked locking, in whatever form, as it will work on any JVM implementation.So, I guess I have to stick with my current model. Please let me know if there is any other way round to avoid the synchronization everytime.
==================================================================== Companion Site: http://www.corej2eepatterns.com J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
|
|