Hi Rick, I'm not especially fond of "explicit" singletons. I tend to avoid them whenever possible. Rather, I've usually attached single-instance objects to a long-lived application object, such as servlets or other framework classes. But that is simply a personal preference.
There is an anomaly I did notice in the code you provided. There are times when I have used singletons, and I used double-checked locking just as you have. Then I came across some articles that pointed out an issue caused by the way the JVM optimizes. To my knowledge, the "double-checked locking" anomaly has not been addressed by Sun. The following article says more on the topic: http://www.javaworld.com/javaworld/javaqa/2002-04/01-qa-0412-doublelock.html Cheers, Phillip. --- Rick Reumann <[EMAIL PROTECTED]> wrote: > > public abstract class Store { > > private static Collection items = null; > private Collection specials = null; > > static { > if ( items == null ) { > synchronized( Store.class) { > if ( items == null ) { > items = //get List of Items from somewhere > } > } > } > } > > public static Collection getItems() { > return items; > } > public Collection getSpecials() { > return specials; > } > } > --- You are currently subscribed to jdjlist as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] http://www.sys-con.com/fusetalk
