Sunday, July 6, 2014



Singleton Factory  Pattern is a design solution where an application wants one and only instance of an class,in all possible scenarios


Steps to create a Singleton Object
-----------------------------------

  • create a default private constructor.
  • create a method which returns an object.
  • make the method accessible by only one thread at a time by adding synchronized keyword.
  • override the clone method i.e throw Clone not support Exception.


Creating an object from a connection pool is a best example for Singleton

Links
------
http://www.javabeginner.com/learn-java/java-singleton-design-pattern
http://howtodoinjava.com/2012/10/22/singleton-design-pattern-in-java/