它是一个单实例类。
原因在于多个虚拟机都可以涉及到相同的单实例类,这些单实例对象可能会同时存在于上下文中,从而导致这些单实例对象并不是全局唯一的。
The instance fields of the singleton will not be globally unique. Because several VMs are involved for what appears to be the same object, several singleton objects might be brought into existence.
由于单例对象作为实例存在而不是类的静态成员,所以你能够惰性地初始化单例对象,即只需要在第一次用它的时候才去创建它。
With singletons implemented as single instances instead of static class members, you can initialize the singleton lazily, creating it only when it is first used.
应用推荐