Skip to content

Latest commit

 

History

History

Singleton Pattern

Singleton Pattern 单例模式

Definition

Ensure a class has only one instance and provide a global point of access to it.
确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例。

Participants

The classes and objects participating in this pattern are:

Singleton (LoadBalancer)

  • defines an Instance operation that lets clients access its unique instance. Instance is a class operation.
  • responsible for creating and maintaining its own unique instance.