jvm knowledge points - java memory model

The Java Memory Model (JMM) is a control mechanism for communication between threads. JMM defines the abstract relationship between the main memory and threads. The shared variables between threads are stored in the main memory (main-memory). Each thread has a private local memory

, a copy of the thread to read/write shared variables is stored in local memory. Local memory is an abstract concept of jmm and does not really exist. He covers caches, write buffers, registers, and other hardware and compiler optimizations. The abstract schematic diagram of the java memory model is as follows

  . It can be seen from the figure that if two threads A and B communicate,

First thread A flushes shared variables to main memory

Secondly, thread B loads and updates shared variables in main memory

The instructions written here are very good: http://www.infoq.com/cn/articles/java-memory-model-1

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326933112&siteId=291194637