Created
January 31, 2013 14:29
-
-
Save lichengwu/4683212 to your computer and use it in GitHub Desktop.
lazy init by placeholder(thread safe)
more graceful than `double check locking`
This file contains hidden or 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
/** | |
* lazy init by placeholder(thread safe) | |
* | |
* @author lichengwu | |
* @version 1.0 | |
* @created 2013-01-31 10:19 PM | |
*/ | |
public class Resource { | |
public static Resource getInstance() { | |
return ResourceHolder.INSTANCE; | |
} | |
private static class ResourceHolder { | |
static final Resource INSTANCE = new Resource(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment