Skip to content

Instantly share code, notes, and snippets.

@michael-wang
Last active December 25, 2015 04:59
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 michael-wang/6920902 to your computer and use it in GitHub Desktop.
Save michael-wang/6920902 to your computer and use it in GitHub Desktop.
A singleton pattern I leaned from: http://antrix.net/posts/2012/java-lazy-initialization/
public class Foo {
private static class InstanceHolder {
public static final Foo instance = new Foo();
}
public static Foo getInstance() {
return InstanceHolder.instance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment