Instead, Scala supports a singleton object construct to support those cases where exactly one instance of a type is needed.
相反,Scala支持单例模式,可以应用于那些一种类型只有一个实例的情况。
Now, we can call the reset method to start off each test run to ensure we are going through the initialization code for the singleton object on every test run.
现在,我们可以在每次测试之前调用reset方法,保证我们在每次测试过程中都会先执行singleton对象的初始化代码。
This class provides a set of classes, or a set of singleton object instances, that include all of the root-level resources and providers (classes annotated with @Provider) in a JAX-RS application.
此类提供了一组类或一组单例(singleton)对象实例,在一个 JAX-RS 应用程序内包括所有的根级别的资源和提供程序(由 @Provider注释的类)。
As a result, instance is now non-null and refers to a valid Singleton object.
结果是,instance现在为非null并引用一个有效的Singleton对象。
This line of code creates a Singleton object and initializes the variable instance to refer to this object.
此行代码创建了一个Singleton对象并初始化变量instance来引用此对象。
The code at BE allocates the memory from the heap for the Singleton object and stores a pointer to that memory in eax.
be处的代码为Singleton对象从堆中分配内存,并将一个指向该块内存的指针存储到eax中。
This line is supposed to ensure that instance will only ever be null or refer to a fully constructed Singleton object.
此行应该确保instance只为null或引用一个构造完整的Singleton对象。
This line is supposed to ensure that instance will only ever be null or refer to a fully constructed Singleton object.
此行应该确保instance只为null或引用一个构造完整的Singleton对象。
应用推荐