JMM defines how threads interact through memory.It used to be somewhat unclear and unnecessarily limiting,and so was revised.
JSR133:Shared variables/Heap memory Memory that can be shared between threads is called shared or heap memory. All instance fields, static fields and array elements are stored in heap memory. We use the term variable to refer to both fields and array elements. Variables local to a method are never shared between threads and are unaffected by the memory model.Multithreads cannot pass each other data for communication,they should use shared variables to do this.Memory that can be shared between threads is called shared memory or heap memory. even though the programmer authored code where a variable is first written and later read, the compiler might reorder the statements as long as it does not change the program semantics. WHY? It is quite common for processors and compilers to do this for performance optimization. As a result, a thread might not see the values it expects to see. This can result in hard to fix bugs in concurrent programs."Visibility""Ordering"
(1)read and load from main memory-->working memory(2)execution: use and assign(3)working memory refresh main memory:story and writekeyword:"synchronized""volatile""final"