Skip to content

Instantly share code, notes, and snippets.

@lichengwu
Created January 31, 2013 14:29
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 lichengwu/4683212 to your computer and use it in GitHub Desktop.
Save lichengwu/4683212 to your computer and use it in GitHub Desktop.
lazy init by placeholder(thread safe) more graceful than `double check locking`
/**
* 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