Monday, June 9, 2014

Singleton Pattern in Java


Simple Note

From reference:
singleton pattern is a design pattern that restricts the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. The concept is sometimes generalized to systems that operate more efficiently when only one object exists, or that restrict the instantiation to a certain number of objects. The term comes from the mathematical concept of a singleton.

Program

https://github.com/benbai123/JSP_Servlet_Practice/tree/master/Practice/JAVA/DesignPattern/src/singleton

Run TestMain.java to test.

There is only one Config instance in whole application.

References:

Singleton pattern

Difference between static class and singleton pattern?

Why use a singleton instead of static methods?

No comments:

Post a Comment