Created
September 28, 2014 08:37
-
-
Save xxnjdlys/a541932ac46bd1262a52 to your computer and use it in GitHub Desktop.
singleton class instance , use volatile
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
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