java reordering and memory model
<p>I am seeing this in the java specs: </p>

<p>If x and y are actions of the same thread and x comes before y in program order, then x happens before y.</p>

<p>and also this  </p>

<p>original code<br>
Thread 1<br>
r2 = A;<br>
B = 1;</p>

<p>valid compiler transformation(compilers are allowed to reorder the instructions in either thread, when this does not affect the execution of that thread in isolation)<br>
Thread 1<br>
B = 1;<br>
r2 = A;  </p>

<p>I am confused with those two things.<br>
if an action x comes before an action y then x should happen before y. if  we consider r2=A for x and B=1 for y, r2=A should happen before B=1. How can there be any reordering, how come B=1 is executed before r2=A if x happens before y is true?.</p>
