According to the Java memory model, instructions can be reordered as long as the execution is properly formed .
So wondering, is it possible that the following codes produce the following output?
[codes] [in the same topic]
long a = System.currentTimeMillis(); long b = System.currentTimeMillis(); long c = System.currentTimeMillis();
[exit]
a == 10, b == 20, c == 15
If this is not possible, then what does the JVM / implementation do to prevent this?
java order java-memory-model
Kurtt.Lin Dec 25 '14 at 3:42 a.m. 2014-12-25 03:42 a.m.
source share