Tagged articles
15 articles
Page 1 of 1
Senior Tony
Senior Tony
Aug 20, 2025 · Backend Development

Why Volatile Solves Memory Visibility and Reordering in Java?

This article explains how the volatile keyword guarantees visibility of shared variables and prevents instruction reordering in Java, covering the Java Memory Model, memory barriers, practical code examples, and the Happens‑Before principle for reliable multithreaded programming.

Instruction ReorderingJMMJava
0 likes · 10 min read
Why Volatile Solves Memory Visibility and Reordering in Java?
Cognitive Technology Team
Cognitive Technology Team
Jul 21, 2025 · Fundamentals

Java Happens‑Before Explained: Volatile, Synchronized & Instruction Reordering

This article explains Java’s happens‑before guarantees, covering instruction reordering, the visibility guarantees of volatile variables and synchronized blocks, and demonstrates how improper reordering can cause stale data or wasted resources through detailed code examples such as FrameExchanger and ValueExchanger.

Instruction ReorderingJavaconcurrency
0 likes · 17 min read
Java Happens‑Before Explained: Volatile, Synchronized & Instruction Reordering
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 Architect Essentials
Java Architect Essentials
Sep 12, 2023 · Fundamentals

Why volatile and synchronized Can't Prevent Instruction Reordering in Java

An in‑depth analysis of Java’s instruction reordering versus ordered execution, illustrating how volatile ensures visibility but not atomicity, how synchronized guarantees atomicity and ordering yet cannot stop bytecode‑level reordering, with detailed DCL singleton bytecode walkthrough and multithreaded examples.

Instruction ReorderingJavaSingleton
0 likes · 7 min read
Why volatile and synchronized Can't Prevent Instruction Reordering in Java
Architecture Digest
Architecture Digest
Aug 10, 2023 · Fundamentals

Instruction Reordering and Ordering in Java Double-Checked Locking

The article explains the difference between instruction reordering and ordering, analyzes how the double‑checked locking pattern can suffer from reordering at the bytecode level, and demonstrates how synchronized provides ordering while volatile only prevents visibility issues, using Java code examples and detailed bytecode analysis.

Instruction ReorderingJavaconcurrency
0 likes · 7 min read
Instruction Reordering and Ordering in Java Double-Checked Locking
Selected Java Interview Questions
Selected Java Interview Questions
Aug 3, 2023 · Backend Development

Instruction Reordering and Ordering in Java: Analysis of Double-Checked Locking

The article explains the distinction between instruction reordering and ordering in Java, analyzes how volatile and synchronized affect memory visibility and atomicity, and demonstrates with bytecode and multithreaded examples why double‑checked locking requires both volatile and synchronized to avoid partially constructed singleton instances.

Instruction ReorderingJavaconcurrency
0 likes · 6 min read
Instruction Reordering and Ordering in Java: Analysis of Double-Checked Locking
Liangxu Linux
Liangxu Linux
May 19, 2023 · Fundamentals

Why CPUs Reorder Instructions and How Memory Barriers Preserve Correctness

The article explains how modern CPUs reorder instructions at compile‑time and runtime, the role of store buffers and invalid queues, why memory barriers are needed for visibility across cores, and compares sequential consistency guarantees on x86 versus ARM/Power architectures.

ARMCPUInstruction Reordering
0 likes · 10 min read
Why CPUs Reorder Instructions and How Memory Barriers Preserve Correctness
High Availability Architecture
High Availability Architecture
Mar 16, 2022 · Fundamentals

Understanding Ordering Issues and Volatile in Java Concurrency

This article explains why intuition fails in multithreaded Java programs, demonstrates ordering problems with simple thread examples, shows how instruction reordering and JIT optimizations can produce unexpected results, and presents the volatile keyword and jcstress testing as reliable solutions to ensure correct visibility and ordering.

Instruction ReorderingJavaMemory Model
0 likes · 9 min read
Understanding Ordering Issues and Volatile in Java Concurrency
Sohu Tech Products
Sohu Tech Products
Oct 27, 2021 · Fundamentals

Understanding Java volatile: Visibility, Atomicity, and Instruction Reordering

This article provides a comprehensive overview of Java's volatile keyword, explaining its pronunciation, role in the Java Memory Model, the three visibility guarantees, how it prevents instruction reordering, its lack of atomicity, practical code examples, and best‑practice scenarios such as double‑checked locking.

Instruction ReorderingJMMJava
0 likes · 21 min read
Understanding Java volatile: Visibility, Atomicity, and Instruction Reordering
Wukong Talks Architecture
Wukong Talks Architecture
Oct 20, 2021 · Fundamentals

Understanding Java volatile: Usage, Memory Model, Visibility, Atomicity, and Instruction Reordering

This article provides a comprehensive guide to Java's volatile keyword, covering its pronunciation, purpose, three core properties, interaction with the Java Memory Model, visibility and atomicity examples, instruction reordering, memory barriers, and practical usage such as double‑checked locking and when to prefer volatile over heavier synchronization mechanisms.

Instruction ReorderingJavaMemory Model
0 likes · 18 min read
Understanding Java volatile: Usage, Memory Model, Visibility, Atomicity, and Instruction Reordering
vivo Internet Technology
vivo Internet Technology
Jan 6, 2021 · Fundamentals

Deep Dive into Java Volatile Keyword: CPU Cache, MESI Protocol, and JMM

The article thoroughly explains how CPU caches and the MESI coherence protocol interact with Java’s Memory Model, detailing the volatile keyword’s role in ensuring visibility and preventing instruction reordering, and illustrates these concepts with examples such as visibility problems and double‑checked locking.

CPU cacheInstruction ReorderingJMM
0 likes · 22 min read
Deep Dive into Java Volatile Keyword: CPU Cache, MESI Protocol, and JMM
Wukong Talks Architecture
Wukong Talks Architecture
Aug 17, 2020 · Fundamentals

Understanding Java volatile: Visibility, Atomicity, and Instruction Reordering

This article explains the purpose and pronunciation of Java's volatile keyword, describes the Java Memory Model and its three guarantees, demonstrates how volatile ensures visibility but not atomicity, explores instruction reordering and memory barriers, and compares volatile with synchronized and other concurrency tools.

Instruction ReorderingJavaMemory Model
0 likes · 20 min read
Understanding Java volatile: Visibility, Atomicity, and Instruction Reordering
Programmer DD
Programmer DD
Jun 4, 2018 · Fundamentals

How Java’s As‑If‑Serial Semantics Keep Single‑Thread Results but Break Multithreaded Guarantees

The article explains why Java and the JVM reorder instructions for performance, the conditions that must be met, how the as‑if‑serial rule protects single‑threaded outcomes, and why the same reordering can violate happens‑before guarantees in multithreaded code, illustrated with concrete examples and code.

Instruction ReorderingJMMJava
0 likes · 8 min read
How Java’s As‑If‑Serial Semantics Keep Single‑Thread Results but Break Multithreaded Guarantees