On the first line , upper is now declared as an object , which is a singleton .
在第一行,upper被定义为一个object,也就是单体模式。
Instead , scala supports a singleton object construct to support those cases where exactly one instance of a type is needed .
相反,scala支持单例模式,可以应用于那些一种类型只有一个实例的情况。
Since an instance of a subclass is an instance of your superclass , you could find multiple instances of the singleton .
由于子类的实例也是单例类的实例,所以可能出现多个单例实例并存的情况。
In this situation , we intend to avoid the expense of grabbing the lock of the singleton class every time the method is called .
在此种解决方法中,我们试图避免在每次该方法被调用时由于对该单例类进行锁住而产生的开销。
In some implementations of creational design patterns in the factory family , the factory is a singleton structured to create an instance of another class .
在工厂模式家族的构建模式的一些实现方式中,工厂类被定义为以单例的方式去创建其他类的实例。
Likewise , with a singleton implemented as single instance , you leave open the possibility of altering the class to create more instances in the future .