728x90
private static Singletone instance;
public static synchronized Singletone getInstance(){
if(instance==null){
instance = new Singletone();
}
return instance;
}
- Thread safe SingleTone pattern
public static Singleton getInstance()
{
if (instance == null)
{
synchronized(Singleton.class) {
instance = new Singleton();
}
}
return instance;
}
- double - checked locking
Double-checked locking example
|
참조 : http://www.ibm.com/developerworks/java/library/j-dcl.html?loc=dwmain
728x90