Originally posted by jacob deiter:
singleton means one instance in the entire application,so a singleton class can be multithreaded?
Actually, this is not true. Google for "singleton considered stupid" for details. The Singleton pattern was made famous by the gang of four book, but it not nearly as simple, or as useful, as they indicate.
The problem is your phrase "entire application". In complex webservices, there may be more than one class loader, and this can cause there to be more than one loaded instance of your "singleton" which really means its not a singleton.
It is also a serious restriction on later "re-use" of your code if you don't make it
thread safe. As any code that uses your code will become unsafe if your code is unsafe.
Today, 4 processor CPUs are cheap. Soon there will be 16 and 32 processor cheap systems.