title: When are changes in Synchronized block visible to other threads
body: <p>Say that I update values of two variables in a synchronized method. Would it be possible that the new values set in synchronized method be visible to other threads <strong>before</strong> exiting the synchronized block? </p>
  
  <pre><code>public synchronized void setValues(){
      a=5;
      // assume thread is preempted after this assignment
      // would the value 5 be visible to other threads?
      // my understanding is that the values will not be flushed to
      // main memory until the lock is released- i.e., until the synchronized
      // method is complete. So the changes will not be visible to other 
      // threads even when not using synchronization
      b=10;
  }
  </code></pre>
  
  <p>Below method is <strong>not</strong> synchronized, so I understand that the thread <strong>may</strong>   see stale values. My question is if the thread is preempted after assignment to a, is it ever possible that the new value "5" for variable a be visible in printValues method?</p>
  
  <pre><code>public void printValues() {
      System.out.println(a + " " + b);
  }
  </code></pre>