Concept : The singleton pattern in Java is a common pattern, there are several types of single-case pattern, there are three kinds: lazy mode, a hungry man mode and registration mode.
The characteristics of the singleton mode: 1, the Singleton class can only have one instance;
2, the Singleton class must create its own unique instance;
3. The Singleton class must provide this instance to all other objects.
The singleton pattern ensures that a class has only one instance, and instantiates itself and provides this instance to the system as a whole. In computer systems, thread pools, caches, log objects, dialog boxes, printers, graphics driver objects are often designed as singleton. These applications are more or less functionally resource-managed. Each PC can have several printers, but only one printer spooler to manage two printer jobs simultaneously called by two requests simultaneously. In summary, selecting Singleton mode is to avoid inconsistent states.
A single-instance pattern of Java design patterns