Skip to content

Instantly share code, notes, and snippets.

@crimx
Created April 14, 2014 15:13
Show Gist options
  • Save crimx/10657026 to your computer and use it in GitHub Desktop.
Save crimx/10657026 to your computer and use it in GitHub Desktop.
Singleton pattern
public class Singleton {
private static Singleton instance = null;
private Singleton() {
//dosomething
}
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