See below code, this puzzles me, in class DynamicPropertyFactory, it locks ConfigurationManager.class, as my understanding, the lock works only in the class or the instance itself. How to understand this?
public class *DynamicPropertyFactory*{
public static *DynamicPropertyFactory* initWithConfigurationSource(AbstractConfiguration config) {
synchronized (**ConfigurationManager.class**) {
if (config == null) {
throw new NullPointerException("config is null");
}
if (ConfigurationManager.isConfigurationInstalled() && config != ConfigurationManager.instance) {
throw new IllegalStateException("ConfigurationManager is already initialized with configuration "
+ ConfigurationManager.getConfigInstance());
}
if (config instanceof DynamicPropertySupport) {
return initWithConfigurationSource((DynamicPropertySupport) config);
}
return initWithConfigurationSource(new ConfigurationBackedDynamicPropertySupportImpl(config));
}
}
}
This is wrong and unclear what you want to say.
lock can be taken on any reference which is not pointing to
null.this line means that on
classobject lock is being taken.