加锁的第一种方式:
public class RootBeanDefinition{
final Object constructorArgumentLock = new Object();
final Object postProcessingLock = new Object();
public void registerExternallyManagedConfigMember(Member configMember) {
synchronized (this.postProcessingLock) {
if (this.externallyManagedConfigMembers == null) {
this.externallyManagedConfigMembers = new HashSet<Member>(1);
}
this.externallyManagedConfigMembers.add(configMember);
}
}
public Method getResolvedFactoryMethod() {
synchronized (this.constructorArgumentLock) {
Object candidate = this.resolvedConstructorOrFactoryMethod;
return (candidate instanceof Method ? (Method) candidate : null);
}
}
}
未完......