Jim, both can achieve the same goal but they are not the same !
Tony, generally a Singleton pattern goes together with a Factory pattern which controls the number of instances you can create.
Usually, the class provides only private constructors and some static methods like getInstance() which return an instance of the class and if needed create some. For instance, the following code allows only one instance to be created:
If you want more instances, just control the number of instances you create by storing them in a List and checking the length of the list before creating a new instance. This way you can manage a pool of instances for your classes, much like the private
String pool is managed...
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
[This message has been edited by Valentin Crettaz (edited December 03, 2001).]