As you study singletons, be aware of a pattern once (but no longer) recommended by Sun that has been shown not to work on multi-processor machines and in some cases in multi-threaded apps on a single processor. If you see code like:
The Singleton Oh Singleton, -- to use or not to use? The grace of pattern overwhelms me, -- You've been the subject of abuse, Or so the sheriffs try to tell me The heat of virtual hot spot machine Makes my initializers slow and lazy But the class loaders are really mean, They make two instances, amazing! And then the garbage man comes in To claim the memory unreferenced And when I call it from the bean It's doubleton, as if I had no preference! The call to get an instance comes along, But gets preempted by someone to blame. I now have a tripleton, and I am prone To crashes, errors, tears, and pain.