多个单例对象存在于两个或多个虚拟机中。
多个单例对象被不同的类加载器同时加载。
Multiple singletons simultaneously loaded by different class loaders.
在这种情况下,一个新的单例对象会被创建。
我们正在做的一件事是支持集群的单例服务。
One of the things we are working on is support for clustered singleton services.
那么,要怎么样来使用单例提供者呢?
单例创建模式是一个通用的编程习语。
The Singleton creation pattern is a common programming idiom.
例如,看一下清单1内所示的这个连接池单例。
For example, take a look at the connection pool singleton in Listing 1.
通过使用这种功能,您可以使用流行的单例模式。
Through this functionality, you can use the popular singleton pattern.
您可以像调用静态方法一样访问单例对象的方法。
You can access methods on singleton objects similar to how you would call static methods.
一种常见用法是用于存储非线程安全类型的单例。
One common use is for storing a singleton of a type that is not thread-safe.
清单4显示了使用方法而非属性来指定适当类的单例。
Listing 4 shows a version of the singleton that USES a method instead of an attribute to specify the appropriate class.
UI组件和应用对象(这是一个单例)都能收到系统事件。
Both UI components and the Application object (which is a singleton) can receive system events.
静态getInstance方法包含单例的模板代码。
The static getInstance method contains the template code for a singleton.
还记得吗,object表示 Scala中的一个单例。
我坚信,在大多数的框架中,使用单例模式时,考虑得都太少了。
It is my true belief that Singleton patterns have been used with far too little thought in most frameworks.
Singletonbean是一个在所属容器上下文中的单例对象。
A singleton bean is a singleton in the context of the owning container.
因此,除非仔细计划,否则应该避免使用JAX - RS资源的单例实例。
Therefore, use of a singleton instance for JAX-RS resources should be avoided unless carefully planned.
他们会发现每次他们要创建一个不同的单例类的时候,都不得不写同样得代码。
Those who use it will find that they often have to write the same code each time they want to create a different Singleton class.
当单例类的副本运行于多个虚拟机中时,每个虚拟机都会为其创建一个实例对象。
When copies of the singleton class run in multiple VMs, an instance is created for each machine.
单例模式确实能够轻而易举解决无须对每个类的引用都进行存储的问题。
They easily solve the problem of not having to store references to every class.
Spring之前为bean提供了两种作用域:单例和原型(或者叫非单例)。
Spring has traditionally offered two scopes for beans: singleton and Prototype (or non-singleton).
相反,Scala支持单例模式,可以应用于那些一种类型只有一个实例的情况。
Instead, Scala supports a singleton object construct to support those cases where exactly one instance of a type is needed.
单例模式是一种有用的控制类访问的途径,他能保证只有一个类实例存在。
Singletons are a useful way to control access to a class, making sure that only one instance can exist.
更有甚者,单例对象能够被状态化;这样,它们可以作为一个状态仓库向外提供服务。
Moreover, singletons can be stateful; in this case, their role is to serve as a unique repository of state.
单例、生成器和工厂方法设计模式被视为是创建型的模式,因它们可协助对象的构建。
The singleton, builder, and factory method design patterns are considered creational patterns, as they assist in the construction of objects.
单例模式同样用于控制像数据库连接或者sockets这样的资源访问。
Singletons often control access to resources such as database connections or sockets.
所以如果两次序列化一个单例对象,这两个序列化得到的对象会持有两个不同的标识。
So if you serialize one singleton twice, the two serialized objects take on separate identities.
这是一个Scala单例(singleton),因为它使用对象声明,而不是类声明。
This is a Scala singleton because it USES the object declaration instead of a class declaration.
单例模式可能是最常用的OOP设计模式之一了;它限制了一个类的对象实例数只能为1。
The singleton pattern is probably one of the most often used OOP design patterns; it restricts the number of object instances of a class to one.
GameServer单例用于它的位置数组,其中保存了游戏面板上每个格子的当前状态。
The GameServer singleton is used for its positions array, which has the current state of each square on the game board.
应用推荐