<p>Every programing language that takes concurrency seriously needs a memory model - and here is why.</p>

<blockquote>
  <p>The memory model is the crux of the concurrency semantics of shared-memory systems. It defines the possible values that a read operation is allowed to return for any given set of write operations performed by a concurrent program, thereby defining the basic semantics of shared variables. In other words, the memory model specifies the set of allowed outputs of a program's read and write operations, and constrains an implementation to produce only (but at least one) such allowed executions. The memory model may and often does allow executions where the outcome cannot be inferred from the order in which read and write operations occur in the program.  It is impossible to meaningfully reason about a program or any part of the programming language implementation without an unambiguous memory model. The memory model defines the possible outcomes of a concurrent programs read and write operations.  Conversely, the memory model also defines which instruction reorderings may be permitted, either by the processor, the memory system, or the compiler.</p>
</blockquote>

<p>This is an excerpt from the paper <a href="https://arxiv.org/pdf/1803.04432.pdf" rel="nofollow noreferrer">Memory Models for C/C++ Programmers</a> which I have co-authored. Even though a large part of it is dedicated to the C++ memory model, it also covers more general areas - 
 starting with the reason why we need a memory model in the first place, explaining the (intuitive) sequential consistent model, and finally the weaker memory models provided by current hardware in x86 and ARM/POWER CPUs.</p>
Why define the Java memory model?
<p>Java's multithreaded code is finally mapped to the operating system thread for execution.   </p>

<p>Is the operating system thread not thread safe?   </p>

<p>Why use the Java memory model to ensure thread safety?Why define the Java memory model?  </p>

<p>I hope someone can answer this question, I have looked up a lot of information on the Internet, still do not understand!  </p>

<p>The material on the web is all about atomicity, visibility, orderliness, and using the cache consistency model as an example, but I don't think it really answers the question.  </p>

<p>thank you very much!</p>