Skip to content

Instantly share code, notes, and snippets.

@nichtemna
Created August 4, 2016 08:42
Show Gist options
  • Save nichtemna/600df2cf19ff7a5dca1d1cfe6f355881 to your computer and use it in GitHub Desktop.
Save nichtemna/600df2cf19ff7a5dca1d1cfe6f355881 to your computer and use it in GitHub Desktop.
Synchronized Singleton
public class Singleton{
private static Singleton instance;
private Singleton(){}
public static synchronized Singleton getInstance(){
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