Created
July 20, 2012 07:19
-
-
Save messi18/3149230 to your computer and use it in GitHub Desktop.
Initialization On Demand Holder idiom
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
class Something { | |
private static class LazySomethingHolder { | |
public static Something something = new Something(); | |
} | |
// this private constructor is necessary | |
private Something(){} | |
public static Something getInstance() { | |
return LazySomethingHolder.something; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment