*Singleton pattern (Singleton)



GOF intent: guarantees that a class has exactly one instance and provides a global access point to it

Role:

singleton (singleton): There is a static instance of itself, and there is a static method that creates and returns the instance if the instance is empty, otherwise returns the instance directly.

 

Implementation points: instance() obtains or creates an instance uniqueInstance is its own instance.

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326944960&siteId=291194637