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() 為啥會調用多次哩盲,這里的synchronized 不是可以鎖住singleFactory.getObject() 的調用嗎秸抚?
Spring 為何需要三級緩存解決循環(huán)依賴,而不是二級緩存前言 如果在日常開發(fā)中我們用new對象的方式倔撞,若多個構造函數相互依賴的話,程序會在運行時一直循環(huán)調用最終導致內存溢出,那么spring是利用三級緩存解決循環(huán)依賴的,讓開發(fā)者無...