Created
March 1, 2010 08:40
-
-
Save TonnyXu/318209 to your computer and use it in GitHub Desktop.
This file contains 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
public class Singleton5 { | |
private static volatile Singleton5 INSTANCE = null; | |
private Singleton5(){ | |
if (null != INSTANCE){ | |
throw new IllegalArgumentException("Already instantiated."); | |
} | |
} | |
public static Singleton5 getInstance(){ | |
if (null == INSTANCE){ | |
synchronized (Singleton5.class) { | |
if (null == INSTANCE){ | |
INSTANCE = new Singleton5(); | |
} | |
} | |
} | |
return INSTANCE; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment