Java Threads and Locks
Readings
- Java Language Specification
- StackOverflow
- Wiki
- Happens-Before俗解
- Understanding JIT
- Video
Memory Reodering
Several mechanisms can produce the reordering. A Just-In-Time(JIT) compiler in a Java Virtual Machine implementation may rearrange code, or the processor. In addition, the memory hierarchy of the architecture on which a Java Virtual Machine implementation is run may make it appear as if code is being reordered.
- Compiler can reorder statements
- Processor can reorder them
- On multi-processor, values not synchronized to global memory
- The memeory model is designed to allow aggressive optimization
- Good for performance