As I understood new java memory model mandates that access to volatile variables is not reordered with access to other variables and thus following code is correct:
Map configOptions;
char[] configText;
volatile boolean initialized = false;
// In Thread A
configOptions = new HashMap();
configText = readConfigFile(fileName);
processConfigOptions(configText, configOptions);
initialized = true;
// In Thread B
while (!initialized)
sleep();
// use configOptions
so when initialized
is set to true
config options is already initialized, but is it visible? I mean is it already in main memory?