Skip to content

Instantly share code, notes, and snippets.

@bhawna94
Created June 2, 2020 13:14
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 bhawna94/cecee76d0425770aac9e9f97385e4586 to your computer and use it in GitHub Desktop.
Save bhawna94/cecee76d0425770aac9e9f97385e4586 to your computer and use it in GitHub Desktop.
class Singleton {
private volatile static Singleton object;
private Singleton() {}
public static Singleton getInstance() {
if (object == null) {
synchronized (Singleton.class) {
if (object == null)
object = new Singleton();
}
}
return object;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment