各位大大好,目前正在k Design Patten,
下面有一段code里面关于synchronized的部分想请教:
public class Singleton{
private volatile static Singleton uniqueInstance;
private Singleton(){}
public static Singleton getInstance(){
if(uniqeInstance == null){
synchronized(Singleton.class){
^^^^^^^^^^^^^^^^^
if(uniqeInstnace == null)
uniqueInstance = new Singleton();
}
}
}
}
对Synchronized block的观念比较薄弱,以前大部分都用this,
用来锁当前物件比较多,想请问这边的Singleton.class锁的是? 感谢!!