title: Volatile variable explanation in Java docs
body: <blockquote>
    <p>when a thread reads a volatile variable, it sees not just the latest change to the volatile, but also the side effects of the code that led up the change</p>
  </blockquote>
  
  <p>This is mentioned at <a href="http://docs.oracle.com/javase/tutorial/essential/concurrency/atomic.html">http://docs.oracle.com/javase/tutorial/essential/concurrency/atomic.html</a></p>
  
  <p>Can someone please provide an example of this? </p>
  
  <p>This first gave me an impression that the thread that reads a volatile variable will synchronize with the writer thread and wait until the write is done. But that clearly is not the case.</p>
  
  <p>An example would help a lot and be much appreciated.</p>
  
  <p>Thanks,
  Mustafa</p>