Quantcast
Channel: Day to day stuff
Viewing all articles
Browse latest Browse all 83

Lock-less singleton pattern

$
0
0
Although the singleton pattern is now know as an anti-pattern, I think it still is a valid choice when you only need one instance in a particular context. Anyway, in Java there are several ways to implement a singleton. For example this one uses a synchronized block:private Singleton singleton = null; protected Singleton createSingleton() { synchronized (this) { // locking on 'this' for

Viewing all articles
Browse latest Browse all 83

Trending Articles