public static synchronized Singleton getInstance() {
if (singleton == null) {
singleton = new Singleton();
}
return singleton;
}
public static Singleton getInstance() {
synchronized(this){
if (singleton == null) {
singleton = new Singleton();
}
}
return singleton;
}
这二者有什么区别和联系? |
|