Skip to content

Instantly share code, notes, and snippets.

@juliano
Created December 9, 2011 16:51
Show Gist options
  • Save juliano/1452340 to your computer and use it in GitHub Desktop.
Save juliano/1452340 to your computer and use it in GitHub Desktop.
LazySingleton
public final class LazySingleton {
private volatile static LazySingleton instance;
private LazySingleton() {
}
public static LazySingleton getInstance() {
if (instance == null) {
synchronized (LazySingleton.class) {
if (instance == null) {
instance = new LazySingleton();
}
}
}
return instance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment