Last active
August 31, 2015 14:47
-
-
Save CN6033/25e163f2b51a06f39262 to your computer and use it in GitHub Desktop.
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 SingletonExample { | |
// Inner class not loaded until some thread reference one of its fileds or methods | |
private static final class InnerSingleton { | |
private static final SingletonExample s = new SingletonExample(); | |
} | |
public static SingletonExample getInstance() { | |
return InnerSingleton.s; | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment