Wednesday, June 9, 2010

Absolutely Singleton.....

Many of Java developers know about singleton pattern and how to create it. But, creating a thread safe Singleton is the real absolute singleton. Otherwise, there are chances for ending up with different objects for different threads, which is totally against singleton.

A sample program given in the discusion here clearly explains how a singleton which is not thread safe can create different objects w.r.t different threads.