Skip to content

Instantly share code, notes, and snippets.

@agustarc
Last active December 22, 2016 00:24
Show Gist options
  • Save agustarc/c39ba0b72699f2c56677901e8f251623 to your computer and use it in GitHub Desktop.
Save agustarc/c39ba0b72699f2c56677901e8f251623 to your computer and use it in GitHub Desktop.
public class Singleton {
private volatile static Singleton instance;
private Singeton() {}
public static Singleton getInstance() {
if (instance == null) {
synchronized(Singleton.class) {
if (instance == null) {
instance == new Singleton();
}
}
}
return instance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment