Originally posted by CL Gilbert:
Whenever a thread enters or exits a synchronized block, the variables within that synchronized block (which will all be in thread local memory) are reconciled with main memory. The memory in the thread is commonly referred to as "thread local memory."
This is very much wrong. Synchronization locks the object, it has no influence how threads deal with memory.
Below is piece of JLS about memory use:
<...>
An use or assign by T of V is permitted only when dictated by execution by T of the program according to the Java programming language's execution model. For example, an occurrence of V as an operand of the + operator requires that a single use action occur on V; an occurrence of V as the left-hand operand of the assignment operator = requires that a single assign action occur. All use and assign actions by a given thread must occur in the order specified by the program being executed by the thread. If the following rules forbid T to perform a required use as its next action, it may be necessary for T to perform a load first in order to make progress.
A store action by T on V must intervene between an assign by T of V and a subsequent load by T of V. (Less formally: a thread is not permitted to lose its most recent assign.)
An assign action by T on V must intervene between a load or store by T of V and a subsequent store by T of V. (Less formally: a thread is not permitted to write data from its working memory back to main memory for no reason.)
After a thread is created, it must perform an assign or load action on a variable before performing a use or store action on that variable. (Less formally: a new thread starts with an empty working memory.)
After a variable is created, every thread must perform an assign or load action on that variable before performing a use or store action on that variable. (Less formally: a new variable is created only in main memory and is not initially in any thread's working memory.)
Provided that all the constraints above and below are obeyed, a load or store action may be issued at any time by any thread on any variable, at the whim of the implementation.