title: How to understand the synchronization order which is a total order?
body: <p>In JLS<a href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.4.4" rel="noreferrer">17.4.4</a>, it says </p>
  
  <blockquote>
    <p>Every execution has a synchronization order. A synchronization order is a total order over all of the synchronization actions of an execution.</p>
  </blockquote>
  
  <p>I know what is a total order. And I know synchronization actions need to be ordered. But what confused me here is why it is a total order for <strong>ALL</strong> of the synchronization actions. For example, an unlock action on monitor <strong>m</strong> happens-before all subsequent lock actions on <strong>m</strong>. But if simultaneously, there is a lock action on monitor <strong>n</strong>, does it need to be ordered after the unlock action on monitor <strong>m</strong>? If not, then why can all of the synchronization actions have a total order? Thank you.</p>