Xuanwu Backend Tech Stack
Xuanwu Backend Tech Stack
Jan 13, 2025 · Backend Development

How Does Java’s volatile Keyword Ensure Thread Visibility and Prevent Reordering?

This article explains how Java's volatile keyword provides visibility guarantees and prevents instruction reordering through memory barriers, illustrates its behavior with code examples, discusses its limitations regarding atomicity, and outlines appropriate usage scenarios such as state flags and double‑checked locking.

Instruction ReorderingJavamemory barrier
0 likes · 9 min read
How Does Java’s volatile Keyword Ensure Thread Visibility and Prevent Reordering?
Java Backend Technology
Java Backend Technology
Mar 17, 2018 · Backend Development

Mastering Java Memory Model: Unlocking Thread Visibility and Concurrency

This article explains Java's concurrency fundamentals, covering shared memory vs. message‑passing models, the abstract structure of the Java Memory Model, instruction reordering, write‑buffer effects, memory barriers, and the happens‑before rules that guarantee correct thread communication.

Javaconcurrencyhappens-before
0 likes · 9 min read
Mastering Java Memory Model: Unlocking Thread Visibility and Concurrency