Merci Head First Design Pattern et Double-checked locking Archive du 17/04/2020 le 27/04/2020
public class Singleton { private volatile static Singleton instance = null; private Singleton () { } public static Singleton getInstance () { Singleton result = instance; if (result == null) { synchronized (Singleton.class) { result = instance; if (result == null) { instance = result = new Singleton (); } } } return result; } }