Top "Singleton" questions

A design pattern that ensures that exactly one application-wide instance of a particular class exists.

Java serialization: readObject() vs. readResolve()

The book Effective Java and other sources provide a pretty good explanation on how and when to use the readObject() …

java serialization singleton
Is spring default scope singleton or not?

Could you please explain why Spring is creating two objects for the configuration of beans shown below, since by default …

java spring dependency-injection singleton spring-ioc
Singleton pattern in nodejs - is it needed?

I recently came across this article on how to write a singleton in Node.js. I know the documentation of …

javascript node.js design-patterns singleton
Singleton with properties in Swift 3

In Apple's Using Swift with Cocoa and Objective-C document (updated for Swift 3) they give the following example of the Singleton …

singleton swift3
How to create singleton class in objective C

How can I create a singleton class in Objective C?

iphone objective-c singleton
How to implement multithread safe singleton in C++11 without using <mutex>

Now that C++11 has multithreading I was wondering what is the correct way to implement lazy initialized singleton without using …

c++ multithreading c++11 singleton atomic
efficient thread-safe singleton in C++

The usual pattern for a singleton class is something like static Foo &getInst() { static Foo *inst = NULL; if(inst == …

c++ singleton thread-safety pthreads
Why does Apple recommend to use dispatch_once for implementing the singleton pattern under ARC?

What's the exact reason for using dispatch_once in the shared instance accessor of a singleton under ARC? + (MyClass *)sharedInstance { // …

ios objective-c singleton automatic-ref-counting
What is the best approach for using an Enum as a singleton in Java?

Building on what has been written in SO question Best Singleton Implementation In Java - namely about using an enum …

java singleton
Where exactly the Singleton Pattern is used in real application?

I was just curious where exactly the singleton pattern is used... I know how the pattern works and where it …

java singleton