Memory model

内存模型是一个相对底层的概念,对于很多编程语言来说,内存模型是对程序员屏蔽的概念。但是如果是涉及并发编程的话,内存模型是一个逃不开的知识点。本文是对自己理解的Java Memory Model的知识梳理。 What is reordering? 你所写的java代码会被compiler、JIT、cache、instructions、CPU执行时重排序。 Source order – how you write the code – Naïve expectation that everything happens exactly as written • Program order – generated machine code presented to the CPU – “Any resemblance to source order is purely coincidental” – It’s all about performance! As long as you can’t tell the difference • Execution order – how the hardware actually executes the code – Speculative execution, instruction reordering, caching, pipeline stalls – It’s all about performance!...

November 17, 2016 · 3 min · magicalne