Java - Design Pattern - Singleton: Difference between revisions
From My Limbic Wiki
(Page créée avec « <source lang="Java"> public class SingletonClass { private static SingletonClass SINGLE_INSTANCE = null; private SingletonClass() {} public static Singleto... ») |
(No difference)
|
Revision as of 01:04, 1 November 2019
<source lang="Java">
public class SingletonClass {
private static SingletonClass SINGLE_INSTANCE = null;
private SingletonClass() {}
public static SingletonClass getInstance() { if (SINGLE_INSTANCE == null) { synchronized (SingletonClass.class) { if (SINGLE_INSTANCE == null) { SINGLE_INSTANCE = new SingletonClass(); } } } return SINGLE_INSTANCE; }
} </source>