Created
July 20, 2017 03:50
-
-
Save circlee/c7894232194a49804ad49d653276231a 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 SingletonTest_2 { | |
static { | |
System.out.println("SingletonTest_2 class load"); | |
} | |
private static SingletonTest_2 instance= null; | |
private SingletonTest_2(){ | |
System.out.println("SingletonTest_2 class new instance"); | |
} | |
public static synchronized SingletonTest_2 getInstance(){ | |
if(instance == null) { | |
instance = new SingletonTest_2(); | |
} | |
return instance; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment