I see the netflix code, in class DynamicPropertyFactory,there's a method like
public static DynamicPropertyFactory getInstance() {
if (config == null) {
synchronized (ConfigurationManager.class) {
if (config == null) {
AbstractConfiguration configFromManager = ConfigurationManager.getConfigInstance();
if (configFromManager != null) {
initWithConfigurationSource(configFromManager);
initializedWithDefaultConfig = !ConfigurationManager.isConfigurationInstalled();
logger.info("DynamicPropertyFactory is initialized with configuration sources: " + configFromManager);
}
}
}
}
return instance;
}
I'm confused on this method that why using synchronized (ConfigurationManager.class), key word synchronized was used on another class ConfigurationManager.class. From my view, synchronized is used in its current class. So, someone can help explain this simplely?
Probably because they expect other classes to access ConfigurationManager on some other thread.