@Test public void test() { final Singleton instA = Singleton.getInstance(); final Singleton instB = Singleton.getInstance(); assertEquals(instA, instB); }
public static Singleton getInstance() { if (instance != null) { return instance; } synchronized (Singleton.class) { instance = new Singleton(); } return instance; }
Singleton { public static Singleton getInstance() { if (instance != null) { return instance; } synchronized (Singleton.class) { instance = new Singleton(); } return instance; } }
Singleton { public static Singleton getInstance() { if (instance != null) { return instance; } synchronized (Singleton.class) { instance = new Singleton(); } return instance; }  }
Singleton { public static Singleton getInstance() { if (instance != null) { return instance; } synchronized (Singleton.class) { instance = new Singleton(); } return instance; }  static Singleton getInstance(); }
Singleton { public static Singleton getInstance() { if (instance != null) { return instance; } synchronized (Singleton.class) { instance = new Singleton(); } return instance; }  static Singleton getInstance();  }