helloworld:design_pattern:singleton:java
Java
Merci Head First Design Pattern et Double-checked locking Archive du 17/04/2020 le 27/04/2020
- singleton.java
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; } }
helloworld/design_pattern/singleton/java.txt · Dernière modification : 2020/05/11 01:19 de root