JVM virtual machine stack, each thread runs with a line stacks, each line stacks saves the thread runtime variable value information.
When a thread accesses the value of an object, the value of the corresponding heap memory variable is first found through the object's reference stack, then the concrete value of the heap memory variable is load into the thread local memory, a copy of the variable is created, and then the thread is no longer associated with the object in the heap memory variable value, but directly modifies the value of the replica At some point after the modification (before the thread exits), the value of the thread variable copy is automatically written to the object in the heap variable. So the value of the objects in the heap changes.
The following diagram depicts this write interaction
Java keyword volatile
Variables modified with the volatile keyword, each time the thread is used, the variable is the most recent value.
Reference Link: http://www.cnblogs.com/aigongsi/archive/2012/04/01/2429166.html
Http://www.ibm.com/developerworks/cn/java/j-jtp06197.html
Java garbage Collection