Skip to content

Instantly share code, notes, and snippets.

@xxnjdlys
Created September 28, 2014 08:37
Show Gist options
  • Save xxnjdlys/a541932ac46bd1262a52 to your computer and use it in GitHub Desktop.
Save xxnjdlys/a541932ac46bd1262a52 to your computer and use it in GitHub Desktop.
singleton class instance , use volatile
private volatile static ImageLoader instance;
/** Returns singleton class instance */
public static ImageLoader getInstance() {
if (instance == null) {
synchronized (ImageLoader.class) {
if (instance == null) {
instance = new ImageLoader();
}
}
}
return instance;
}
protected ImageLoader() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment