synchronized (this.singletonObjects) {
// Consistent creation of early reference within full singleton lock
singletonObject = this.singletonObjects.get(beanName);
if (singletonObject == null) {
singletonObject = this.earlySingletonObjects.get(beanName);
if (singletonObject == null) {
ObjectFactory<?> singletonFactory = this.singletonFactories.get(beanName);
if (singletonFactory != null) {
singletonObject = singletonFactory.getObject();
this.earlySingletonObjects.put(beanName, singletonObject);
this.singletonFactories.remove(beanName);
}
}
}
}
singleFactory.getObject() 為啥會(huì)調(diào)用多次,這里的synchronized 不是可以鎖住singleFactory.getObject() 的調(diào)用嗎?
Spring 為何需要三級(jí)緩存解決循環(huán)依賴,而不是二級(jí)緩存前言 如果在日常開發(fā)中我們用new對(duì)象的方式,若多個(gè)構(gòu)造函數(shù)相互依賴的話,程序會(huì)在運(yùn)行時(shí)一直循環(huán)調(diào)用最終導(dǎo)致內(nèi)存溢出,那么spring是利用三級(jí)緩存解決循環(huán)依賴的,讓開發(fā)者無...