< Back
Page 4 of 4
This chapter is from the book
Summary
Summary
Code that supports Singleton ensures that a class has only one instance and provides a global point of access to it. A common way to achieve this is through lazy-initialization of a singleton object, instantiating it only when the singleton is first needed. In a multi-threaded environment, you must take care to manage the collaboration of threads that may access a singleton’s methods and data at approximately the same time.
Uniqueness of a class’s or an object’s role does not imply that the Singleton pattern is in use. The _Singleton pattern centralizes authority in a single instance of a class.
< Back
Page 4 of 4