Posts

Showing posts with the label Bill Pugh Singleton

Singleton Design Pattern

      We have various ways to create singleton class in java, first of all what is singleton and why it is required ?       Singleton class will restrict you by creating a new object using new keyword, It provides the same single instance for the single JVM instance. If you want some introduction about design patterns please have a look it my post here .This post is little bit too long, so please hold on  your breath.       So the first step is to know what wikipedia says,       The singleton pattern is a software design pattern that restricts the instantiation of a class to one.       Second step is to map singleton pattern to the real world example,             Each country will have a single President   post, for every some years (normally 5) the people for the post will change but the country will hold only one Preside...