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 为何需要三级缓存解决循环依赖,而不是二级缓存前言 如果在日常开发中我们用new对象的方式,若多个构造函数相互依赖的话,程序会在运行时一直循环调用最终导致内存溢出,那么spring是利用三级缓存解决循环依赖的,让开发者无...