Skip to content

Instantly share code, notes, and snippets.

@nanjingdaqi
Created November 4, 2018 06:00
Show Gist options
  • Save nanjingdaqi/8fd36599458811418e820d9621cf7816 to your computer and use it in GitHub Desktop.
Save nanjingdaqi/8fd36599458811418e820d9621cf7816 to your computer and use it in GitHub Desktop.
double check singleton
public class Sig {
private static volatile Sig sInstance;
private Sig() {
}
public static Sig getInstance() {
if (sInstance == null) {
synchronized(Sig.class) {
if (sInstance == null) {
sInstance = new Sig();
}
}
}
return sInstance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment