Last active
December 25, 2015 04:59
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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