Skip to content

Instantly share code, notes, and snippets.

@IamLizu
Created September 29, 2019 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IamLizu/62dfadda2924357cf61e14e5e3215b82 to your computer and use it in GitHub Desktop.
Save IamLizu/62dfadda2924357cf61e14e5e3215b82 to your computer and use it in GitHub Desktop.
public class Singleton {
private volatile static Singleton Instance();
private Singleton () {}
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