Singleton is OK for some situations, such as when you are running a standalone application. You are only guaranteed to get one instance per classloader.
For other situations (such as web application servers,
J2EE, etc.) this
pattern breaks down horribly. You would have to use some other paradigm (JNDI registry, etc.) to ensure you have only one instance of something.
Singleton has other problems, such as the fact that you can never extend/inherit from a Singleton. (Some would argue this is a feature.)
Also, you have be careful if your Singleton is serializable, because the JVM may create a second instance of your class when it is deserialized. The book "Effective Java" by Joshua Bloch has a great explanation of that issue.
Also, make sure your factory method is synchronized. Otherwise 2 threads may create 2 instances in the factory method.
Geoffrey
[ March 09, 2005: Message edited by: Geoffrey Falk ]