SleepyEgg

Tech News, Deals, & Games

  • Increase font size
  • Default font size
  • Decrease font size
Home News Tech News Java singleton design pattern

Java singleton design pattern

E-mail Print PDF
singleton is a design pattern that focus on object creation. When a class is implemented using singleton, one and only one such instance can be created in a JVM. Usual implementation will be: 1. making constructor private 2. use a public static "getInstance" method to get an instance object 3. use either lazy instantiation or instantiate it statically 4. if lazy instatiation is used, must synchronized "getInstance" method. 5. the singleton object is private static instace field In some cases you may prefer a abstract class with all static methods. Share Link:
Bookmark Google Yahoo MyWeb Del.icio.us Digg Facebook Myspace Reddit Ma.gnolia Technorati Stumble Upon
Comments (0)Add Comment

Write comment
You must be logged in to a comment. Please register if you do not have an account yet.

busy
 

Polls

Which is your favorite Game Console?
 

Login

               No account yet?