Skip to content

Instantly share code, notes, and snippets.

@simekadam
Created October 7, 2013 20:18
Show Gist options
  • Save simekadam/6874243 to your computer and use it in GitHub Desktop.
Save simekadam/6874243 to your computer and use it in GitHub Desktop.
public class Singleton{
private static volatile 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