title: Happens-before with different monitors
body: <p>Somewhere on this site (I don't remember the question) someone claimed that happens-before relashionship holds for different monitors and for different volatile variables, i.e.</p>
  
  <pre><code>// Thread T1
  synchronized(O1)
  {
  }
  
  // Thread T2
  synchronized(O2)
  {
  }
  </code></pre>
  
  <p>If thread T2 enters synchronized(O2){} block after thread T1 leaves synchronized(O1){} block, T2 will see all changes made by T1. The explanation was that when a thread leaves synchronized block (or writes to volatile variable) it flushes it's cache into the memory. And when a thread enters synchronized block (or reads volatile variable) it discards it's cache and reads from the memory. Is it true?</p>