title: Is 'program order' in Java allows reordering?
body: <p>In one thread I have</p>
  
  <pre><code>write a = 0
  write a = 1
  write volatile flag = 1
  </code></pre>
  
  <p>In 2nd thread I have</p>
  
  <pre><code>read volatile flag // This always happens after I write volatile flag in thread 1
  read a
  </code></pre>
  
  <p>Can a reordering happen so I see <code>read a</code> returning 0 in the 2nd thread? </p>
  
  <p>If not, could someone, please, explain in detail why?</p>
  
  <p>I'm asking becuase I'm puzzled by this definition from the JLS:</p>
  
  <blockquote>
    <p>Among all the inter-thread actions performed by each thread t, the
    program order of t is a total order that reflects the order in which
    these actions would be performed according to the intra-thread
    semantics of t.</p>
  </blockquote>
  
  <p>It looks as if allows for reordering in this situation?</p>