Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

Singleton Basics

The lifetime of a typical singleton object is not tied to the client. Consider .NET Remoting, for instance. When a client makes a call, the .NET Remoting service provides a thread from its pool, which then accesses the object. Multiple clients can access the same object on multiple different threads if they make concurrent calls.

If the singleton object is stateless (in other words, it doesn’t provide any class properties or member variables), there’s really nothing to worry about. Any variables created in a method body are local to the current call. In this case, a singleton object performs like a single-call object. In fact, contrary to what you might expect, a singleton object used in this way might even perform better because it doesn’t need to be destroyed and re-created for each call. More likely, however, you’ll use a singleton design only if you need to maintain some sort of shared information.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial