title: Why is volatile necessary in Java
body: <p>In Java, all threads uses the same heap. If a thread is caching the operations to the heap, when exactly will it flush to heap?</p>
  
  <p>I have read so many posts but not able to find the answers.</p>
  
  <p>Thanks.</p>