Tagged articles
instruction reordering
16 articles · Page 1 of 1
The article explains that Java's synchronized keyword guarantees mutual exclusion but cannot stop the CPU or compiler from reordering instructions inside the critical section, leading to a broken double‑checked locking pattern unless the instance field is declared volatile.
ConcurrencyJavaSynchronized
0 likes · 5 min read

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.
JMMJavainstruction reordering
0 likes · 10 min read

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.
ConcurrencyJavainstruction reordering
0 likes · 17 min read

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.
Javainstruction reorderingmemory barrier
0 likes · 9 min read

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.
ConcurrencyJavaSynchronized
0 likes · 7 min read

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.
ConcurrencyJavaSynchronized
0 likes · 7 min read

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.
ConcurrencyJavaSynchronized
0 likes · 6 min read

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

This article provides a comprehensive guide to Java's volatile keyword, covering its pronunciation, role in the Java Memory Model, visibility guarantees, lack of atomicity, instruction reordering prevention, memory barriers, and practical usage patterns such as double‑checked locking and atomic classes.
JMMatomicityinstruction reordering
0 likes · 20 min read

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.
Javainstruction reorderingjcstress
0 likes · 9 min read

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.
JMMJavaatomicity
0 likes · 21 min read

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.
Javaatomicityinstruction reordering
0 likes · 18 min read

The article explains how Java's memory model and compiler optimizations can reorder writes, causing ordering bugs in multithreaded programs, demonstrates the issue with simple and jcstress tests, and shows that declaring the flag as volatile restores the expected behavior.
instruction reorderingjcstressmemory model
0 likes · 10 min read

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 cacheConcurrencyJMM
0 likes · 22 min read

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.
Javaatomicityinstruction reordering
0 likes · 20 min read

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.
ConcurrencyJMMJava
0 likes · 8 min read
