Share on Google+Share on Google+

Singleton class

Advertisement
The singleton design pattern allows to have one and only one instance of an object to be created within the whole application.

Singleton class

     

Singleton Design Pattern:

The singleton design pattern allows to have one and only one instance of an object to be created within the whole application. This can be achieved in java by making a Singleton  class

Benefits: 
Singleton pattern provides 
-- access only to the unique instances,
-- permits a variable number of instances, 
-- provides more flexibility than class operations. 
-- it reduces name space, and 
-- allows refinement of operations and representations, 

Usage: 
-- It is used only at those places where the user requires only one instance of a class to be operating through out the application. 
-- It is mostly used in the multi-threaded environments.
-- They often work as global variables permitting the allocation and initialization whenever required. 

Read more at:

www.roseindia.net/java/beginners/SingletonPattern.shtml

Advertisements

Posted on: June 11, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: Singleton class  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0