Tagged articles
97 articles
Page 1 of 1
Tech Freedom Circle
Tech Freedom Circle
Apr 25, 2026 · Fundamentals

Why a Simple Singleton Answer Failed an Alibaba Interview: The Real Role of volatile, Memory Barriers, and Happens‑Before

The article dissects an Alibaba interview question about the volatile modifier, showing why answering only with a lazy‑loaded singleton is insufficient, and explains how volatile prevents instruction reordering, establishes memory barriers, and creates happens‑before relationships to make double‑checked locking safe.

Happens-beforeJMMJava
0 likes · 20 min read
Why a Simple Singleton Answer Failed an Alibaba Interview: The Real Role of volatile, Memory Barriers, and Happens‑Before
Deepin Linux
Deepin Linux
Sep 13, 2025 · Fundamentals

Why the volatile Keyword Matters in C/C++: The Hidden Hero of Concurrency and Hardware

This article explains the purpose, mechanics, and practical use cases of the C/C++ volatile qualifier, showing how it forces memory accesses, prevents harmful compiler optimizations, and ensures correct behavior in multithreaded, interrupt-driven, and hardware‑interfacing programs while also highlighting its limitations and performance impact.

CHardwareMemory Model
0 likes · 32 min read
Why the volatile Keyword Matters in C/C++: The Hidden Hero of Concurrency and Hardware
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 20, 2025 · Fundamentals

When Java volatile Falls Short: Visibility, Happens‑Before, and Performance

This article explains how Java’s volatile keyword ensures variable visibility across threads, details its full visibility and happens‑before guarantees, explores instruction reordering challenges, outlines scenarios where volatile alone is insufficient, and discusses performance considerations and alternative synchronization mechanisms.

Happens-beforeJavamemory visibility
0 likes · 14 min read
When Java volatile Falls Short: Visibility, Happens‑Before, and Performance
The Dominant Programmer
The Dominant Programmer
Jul 9, 2025 · Fundamentals

Mastering Java Thread Communication: volatile, synchronized, wait/notify, and Piped Streams

This article explains how Java threads interact using volatile for visibility, synchronized blocks for mutual exclusion, wait/notify (and Condition) for coordination, piped streams for one‑way byte communication, as well as Thread.join and ThreadLocal utilities, providing concrete code examples, best‑practice guidelines, and performance considerations.

JavaPipedStreamThreadLocal
0 likes · 23 min read
Mastering Java Thread Communication: volatile, synchronized, wait/notify, and Piped Streams
Liangxu Linux
Liangxu Linux
May 26, 2025 · Fundamentals

Why the ‘volatile’ Keyword Saves Your Embedded C Code (And Common Misconceptions)

Understanding C’s volatile keyword is essential for embedded programming: it prevents compiler optimizations on variables that may change unexpectedly, such as hardware registers or signal‑handler flags, and clarifies common misconceptions about memory visibility, atomicity, and proper usage scenarios.

CCompiler Optimizationembedded programming
0 likes · 9 min read
Why the ‘volatile’ Keyword Saves Your Embedded C Code (And Common Misconceptions)
Cognitive Technology Team
Cognitive Technology Team
May 2, 2025 · Backend Development

Stopping Java Threads: interrupt, volatile flag, and combined approaches

This article explains three methods for safely terminating Java threads—using the interrupt mechanism, a volatile boolean flag, and a combination of both—detailing their principles, code examples, advantages, disadvantages, and a comparative summary to guide developers in choosing the appropriate technique.

JavaThread Interruptionmultithreading
0 likes · 8 min read
Stopping Java Threads: interrupt, volatile flag, and combined approaches
Java Tech Enthusiast
Java Tech Enthusiast
Mar 4, 2025 · Backend Development

When to Use volatile with ConcurrentHashMap and Spring Bean Thread Safety

A ConcurrentHashMap is internally thread‑safe, so a volatile declaration is only required when its reference may be reassigned (or the field is final), while Spring singleton beans with mutable fields are not thread‑safe and should be made stateless, prototype‑scoped, or synchronized for composite operations.

ConcurrentHashMapJavaspring
0 likes · 13 min read
When to Use volatile with ConcurrentHashMap and Spring Bean Thread Safety
Java Tech Enthusiast
Java Tech Enthusiast
Feb 17, 2025 · Fundamentals

Why a Java Volatile Example May Terminate Without Volatile

The program that loops on a non‑volatile boolean flag sometimes terminates because changing the counter to a volatile int or to an Integer causes the JVM to emit hidden memory barriers on reference writes, making the flag visible, but this behavior is JVM‑specific and not a reliable substitute for declaring the flag volatile.

HotSpotJVMJava
0 likes · 11 min read
Why a Java Volatile Example May Terminate Without Volatile
Su San Talks Tech
Su San Talks Tech
Feb 17, 2025 · Fundamentals

Why Changing int to Integer Lets a Non‑volatile Java Loop Terminate

This article explores a classic Java concurrency puzzle where a non‑volatile flag causes an infinite loop, examines how modifying the loop variable from int to Integer or adding volatile affects termination, and explains the underlying JVM memory‑barrier behavior revealed by DeepSeek.

HotSpotJMMJava
0 likes · 11 min read
Why Changing int to Integer Lets a Non‑volatile Java Loop Terminate
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?
Sanyou's Java Diary
Sanyou's Java Diary
Sep 26, 2024 · Fundamentals

Mastering Java volatile: Visibility, Atomicity, and Memory Model Explained

This article provides a comprehensive guide to Java's volatile keyword, covering its pronunciation, core features such as visibility, lack of atomicity, and instruction reordering prevention, the Java Memory Model, cache‑coherence mechanisms, practical code examples, and best‑practice scenarios like double‑checked locking and when to prefer volatile over heavier synchronization constructs.

JMMMemory Modelmultithreading
0 likes · 21 min read
Mastering Java volatile: Visibility, Atomicity, and Memory Model Explained
IT Services Circle
IT Services Circle
Mar 17, 2024 · Backend Development

Understanding the volatile Keyword in Java Concurrency

This article explains the Java volatile keyword, covering its underlying principles, effects on visibility and instruction reordering, appropriate usage scenarios, limitations, and provides a practical code example demonstrating how volatile ensures thread visibility and prevents dead loops in multithreaded programs.

CASJavaatomic
0 likes · 6 min read
Understanding the volatile Keyword in Java Concurrency
Liangxu Linux
Liangxu Linux
Feb 29, 2024 · Fundamentals

Master static, volatile, sizeof, and I2C for Embedded C

This guide explains the purposes and effects of the C/C++ static and volatile keywords, compares the sizeof operator with strlen, describes reliable methods for comparing floating‑point numbers, outlines how floating‑point operations affect STM32 interrupt performance, and provides a concise overview of the I²C protocol and address configuration on STM32 devices.

C++I2CSTM32
0 likes · 9 min read
Master static, volatile, sizeof, and I2C for Embedded C
Open Source Linux
Open Source Linux
Feb 27, 2024 · Fundamentals

Unlocking static, volatile, sizeof & I2C: Essential C Tips for Embedded Engineers

This article explains the roles of the static and volatile keywords, compares sizeof and strlen, shows how to reliably compare floating‑point numbers, discusses the impact of floating‑point operations on STM32 interrupt performance, and outlines the I2C protocol and address configuration for embedded systems.

C programmingI2Cembedded systems
0 likes · 13 min read
Unlocking static, volatile, sizeof & I2C: Essential C Tips for Embedded Engineers
Liangxu Linux
Liangxu Linux
Jan 21, 2024 · Fundamentals

5 Common Embedded Firmware Bugs and How to Prevent Them

This article outlines five typical errors that plague embedded firmware—race conditions, non‑reentrant functions, missing volatile qualifiers, stack overflows, and heap fragmentation—and provides concrete best‑practice guidelines to detect, avoid, and mitigate each issue.

Reentrancyfirmwarerace condition
0 likes · 13 min read
5 Common Embedded Firmware Bugs and How to Prevent Them
Liangxu Linux
Liangxu Linux
Jan 17, 2024 · Fundamentals

C volatile Techniques: Multithreading, Embedded, Debugging, Pointer Casting

This article explores advanced applications of the C volatile keyword, demonstrating its role in multithreaded synchronization, embedded hardware register access, disabling compiler optimizations for debugging, and safe pointer type casting, each illustrated with complete, runnable code examples.

CDebuggingpointer casting
0 likes · 7 min read
C volatile Techniques: Multithreading, Embedded, Debugging, Pointer Casting
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
Top Architect
Top Architect
Aug 17, 2023 · Backend Development

Thread Communication in Java: volatile, wait/notify, CountDownLatch, ReentrantLock+Condition, and LockSupport

This article explains five Java thread‑communication techniques—volatile variables, Object.wait()/notify(), CountDownLatch, ReentrantLock with Condition, and LockSupport—providing code examples and detailed explanations of how each method works and its synchronization behavior, including sample programs that add elements to a list, demonstrate notification timing, and show how locks are acquired and released.

CountDownLatchJavaLockSupport
0 likes · 11 min read
Thread Communication in Java: volatile, wait/notify, CountDownLatch, ReentrantLock+Condition, and LockSupport
Tencent Cloud Developer
Tencent Cloud Developer
Aug 17, 2023 · Backend Development

Java Memory Model and Concurrent Programming: Visibility, Ordering, and Atomicity

The article explains how the Java Memory Model addresses concurrency challenges by defining visibility, ordering, and atomicity guarantees through mechanisms such as volatile, synchronized, cache coherence, memory barriers, CAS operations, and happens‑before relationships, enabling correct and portable multi‑threaded programming.

CASConcurrent ProgrammingHappens-before
0 likes · 25 min read
Java Memory Model and Concurrent Programming: Visibility, Ordering, and Atomicity
Architect
Architect
Aug 16, 2023 · Backend Development

5 Practical Ways to Implement Thread Communication in Java

This article compares five Java thread‑communication techniques—volatile flag, Object.wait()/notify(), CountDownLatch, ReentrantLock with Condition, and LockSupport—by presenting concrete code examples, explaining their underlying mechanisms, and discussing their advantages and drawbacks.

CountDownLatchJavaLockSupport
0 likes · 13 min read
5 Practical Ways to Implement Thread Communication 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
Top Architect
Top Architect
Oct 17, 2022 · Backend Development

Understanding Java Locks: volatile, synchronized, monitor, CAS, and AQS

This article explains why locks are needed in Java, describes the fundamentals of volatile and synchronized, details the monitor‑based implementation of synchronized, introduces CAS operations, and outlines advanced lock mechanisms such as biased, lightweight, lock coarsening, elimination, and the AbstractQueuedSynchronizer framework.

AQSCASJava
0 likes · 11 min read
Understanding Java Locks: volatile, synchronized, monitor, CAS, and AQS
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
JD Tech
JD Tech
Nov 19, 2021 · Fundamentals

Understanding the Java Memory Model (JMM) and JSR‑133: Concepts, Guarantees, and Memory Barriers

This article explains the Java Memory Model (JMM) defined by JSR‑133, covering its core theory, the role of keywords like volatile, synchronized, and final, the underlying hardware memory models, cache‑coherence protocols, happens‑before rules, memory barriers, and how they ensure atomicity, visibility, and ordering in multithreaded Java programs.

Happens-beforeJSR133Memory Model
0 likes · 21 min read
Understanding the Java Memory Model (JMM) and JSR‑133: Concepts, Guarantees, and Memory Barriers
Java Tech Enthusiast
Java Tech Enthusiast
Nov 9, 2021 · Fundamentals

Understanding Variable Visibility and the volatile Keyword in Java

The article explains Java’s variable‑visibility problem in multithreaded code, describes the Java Memory Model and the happens‑before rules, and shows how synchronization or declaring a field volatile (as in double‑checked‑locking Singleton) guarantees that updates become visible across threads and prevents instruction reordering.

JMMJavamultithreading
0 likes · 13 min read
Understanding Variable Visibility and the volatile Keyword in Java
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
Programmer DD
Programmer DD
Aug 15, 2021 · Fundamentals

Is Java’s long and double Access Truly Atomic? A Deep Dive

Through a multithreaded test program, this article explores whether Java’s 64‑bit long and double types are accessed atomically on 32‑bit and 64‑bit JVMs, explains the JVM memory model rules, and shows how volatility and hardware affect atomicity.

JVMJavaLong
0 likes · 10 min read
Is Java’s long and double Access Truly Atomic? A Deep Dive
Java Interview Crash Guide
Java Interview Crash Guide
Aug 1, 2021 · Fundamentals

How Does Java’s volatile Keyword Ensure Visibility and Ordering?

This article explains the two core properties of Java's volatile keyword—visibility and ordering—detailing how lock prefixes, memory barriers, and happens‑before relationships provide memory consistency, and compares volatile's implementation with synchronized blocks and CAS operations.

Happens-beforeJavaMemory Model
0 likes · 14 min read
How Does Java’s volatile Keyword Ensure Visibility and Ordering?
TAL Education Technology
TAL Education Technology
May 13, 2021 · Backend Development

Understanding Java Concurrency: Volatile, Synchronized, JMM, and MESI

This article provides a comprehensive tutorial on Java concurrency, covering the usage and implementation principles of the volatile and synchronized keywords, the Java Memory Model, the MESI cache protocol, common visibility and reordering issues, and practical code examples for designing efficient multithreaded solutions.

JMMJavaMESI
0 likes · 17 min read
Understanding Java Concurrency: Volatile, Synchronized, JMM, and MESI
Su San Talks Tech
Su San Talks Tech
Apr 28, 2021 · Fundamentals

Master Java Concurrency: HashMap, ConcurrentHashMap, JMM, Thread Pools & More

Explore deep Java concurrency concepts, from HashMap internals and its JDK7/JDK8 differences to ConcurrentHashMap’s lock strategies, thread states, memory models, volatile, CAS, synchronized, thread pools, AQS, and common interview questions, providing comprehensive insights for mastering multithreaded programming.

HashMapJMMThreadPool
0 likes · 38 min read
Master Java Concurrency: HashMap, ConcurrentHashMap, JMM, Thread Pools & More
Top Architect
Top Architect
Apr 6, 2021 · Backend Development

Why ConcurrentHashMap.get() in Java 8 Is Lock‑Free

The article explains how Java 8's ConcurrentHashMap implements a lock‑free get() operation by replacing the Segment design with Node objects, using volatile fields and CAS, and how the volatile‑marked table array ensures visibility during resizing, making reads both safe and efficient.

Backend DevelopmentConcurrentHashMapJava
0 likes · 10 min read
Why ConcurrentHashMap.get() in Java 8 Is Lock‑Free
Top Architect
Top Architect
Mar 11, 2021 · Fundamentals

Why ConcurrentHashMap.get() in Java 8 Is Lock‑Free

This article explains how Java 8's ConcurrentHashMap implements the get operation without acquiring locks by using volatile fields, CAS, and a simplified node structure, contrasting it with the segment‑based design of JDK 1.7 and detailing the memory‑visibility guarantees provided by volatile.

ConcurrentHashMapJDK8Java
0 likes · 9 min read
Why ConcurrentHashMap.get() in Java 8 Is Lock‑Free
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
Code Ape Tech Column
Code Ape Tech Column
Dec 17, 2020 · Backend Development

108 Essential Java Multithreading Interview Questions and Answers

This comprehensive guide compiles 108 common Java multithreading interview questions, covering the purpose of concurrency, thread creation methods, lifecycle nuances, synchronization utilities, memory visibility, thread safety levels, debugging techniques, executor frameworks, concurrent collections, atomic operations, lock implementations, and best‑practice recommendations.

ExecutorJavaSynchronization
0 likes · 59 min read
108 Essential Java Multithreading Interview Questions and Answers
High Availability Architecture
High Availability Architecture
Dec 7, 2020 · Fundamentals

Understanding the Java Memory Model: History, Definition, and Practical Implications

This article explains the evolution from single‑core to multi‑core computing, introduces memory models as a protocol for ordering memory operations, details the Java memory model’s definition, its impact on Java and other languages, and provides practical examples and insights into synchronization, volatile, and happens‑before rules.

Happens-beforeJavaMemory Model
0 likes · 26 min read
Understanding the Java Memory Model: History, Definition, and Practical Implications
Top Architect
Top Architect
Sep 4, 2020 · Fundamentals

Understanding the volatile Keyword and Thread Synchronization in Java

This article explains how the volatile keyword ensures visibility of shared variables across threads, illustrates its behavior with examples and code, discusses its limitations regarding atomicity, and presents solutions using synchronized blocks or atomic classes for proper thread synchronization in Java.

JavaSynchronizationatomic
0 likes · 8 min read
Understanding the volatile Keyword and Thread Synchronization in Java
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Aug 26, 2020 · Backend Development

Testing Volatile Thread Safety and Comparing LongAdder vs AtomicInteger Performance in Java

This article examines the thread‑safety of the volatile keyword under multi‑write scenarios, demonstrates its failure with a concurrent counter test, and benchmarks LongAdder against AtomicInteger using JMH, revealing LongAdder’s superior performance under high contention and AtomicInteger’s advantage in low‑contention environments.

AtomicIntegerJMHJava
0 likes · 8 min read
Testing Volatile Thread Safety and Comparing LongAdder vs AtomicInteger Performance in Java
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
Architect
Architect
Aug 8, 2020 · Fundamentals

Understanding Java Memory Model, Volatile, Atomicity, Visibility, and Ordering

This article explains the Java memory model, how variables are stored in main and working memory, and why concurrency issues like dirty reads, non‑atomic operations, and instruction reordering occur, while detailing the roles of volatile, synchronized, locks, and atomic classes in ensuring visibility, ordering, and atomicity.

JavaMemory Modelatomicity
0 likes · 21 min read
Understanding Java Memory Model, Volatile, Atomicity, Visibility, and Ordering
Programmer DD
Programmer DD
Jul 2, 2020 · Fundamentals

Why volatile Doesn’t Guarantee Atomicity in Java and How to Use It Correctly

This article explains the Java memory model, the role of the volatile keyword in ensuring visibility and ordering, why it cannot provide atomicity for compound operations, and presents proper synchronization techniques such as synchronized, Lock, AtomicInteger, and double‑checked locking.

Happens-beforeJavaMemory Model
0 likes · 27 min read
Why volatile Doesn’t Guarantee Atomicity in Java and How to Use It Correctly
Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Jun 30, 2020 · Fundamentals

Understanding Java Volatile Keyword and Memory Model

This article provides a comprehensive tutorial on Java's volatile keyword, covering its role in the Java Memory Model, the three concurrency fundamentals of atomicity, visibility, and ordering, and detailed explanations of volatile's visibility, ordering guarantees, implementation mechanisms, and a source code example.

JMMJavaMemory Model
0 likes · 10 min read
Understanding Java Volatile Keyword and Memory Model
Java Captain
Java Captain
May 14, 2020 · Fundamentals

Understanding Java volatile: Visibility, Ordering, and Usage in Concurrent Programming

This article explains Java's volatile keyword as a lightweight synchronization mechanism, covering its role in ensuring visibility, ordering, and limited atomicity, the underlying Java Memory Model concepts of atomicity, visibility, and ordering, and when volatile is appropriate or insufficient in concurrent programming.

JavaMemory ModelSynchronization
0 likes · 12 min read
Understanding Java volatile: Visibility, Ordering, and Usage in Concurrent Programming
Programmer DD
Programmer DD
Mar 22, 2020 · Fundamentals

Why Use Locks in Java? Understanding volatile, synchronized, and CAS

This article explains why Java uses locks to prevent dirty reads and data inconsistency, compares volatile and synchronized mechanisms, details monitor-based lock implementation, lock optimizations like biased and lightweight locks, introduces CAS and AbstractQueuedSynchronizer, and illustrates these concepts with code examples and diagrams.

AQSCASJava
0 likes · 13 min read
Why Use Locks in Java? Understanding volatile, synchronized, and CAS
Architecture Digest
Architecture Digest
Mar 14, 2020 · Fundamentals

Understanding the Java Memory Model (JMM) and Its Concurrency Rules

This article explains the Java Memory Model, describing how main memory and thread‑local working memory interact, the eight primitive actions defined by the JVM, the special semantics of volatile, long and double variables, and how these concepts underpin atomicity, visibility and the happens‑before principle in concurrent Java programs.

Happens-beforeJMMJava
0 likes · 23 min read
Understanding the Java Memory Model (JMM) and Its Concurrency Rules
FunTester
FunTester
Feb 18, 2020 · Backend Development

Why Java’s volatile Can’t Replace Synchronization: Understanding Memory Consistency and Deadlocks

This article explains Java memory‑consistency problems, demonstrates how stale values arise with unsynchronized threads, shows how volatile and synchronized provide happens‑before guarantees, and illustrates common synchronization pitfalls such as reference locks and deadlocks with concrete code examples.

JavaMemory ModelSynchronization
0 likes · 7 min read
Why Java’s volatile Can’t Replace Synchronization: Understanding Memory Consistency and Deadlocks
Java Captain
Java Captain
Nov 3, 2019 · Backend Development

Understanding Java Locks, Synchronization, and Concurrency Mechanisms

This article explains why locks are needed in Java, compares volatile and synchronized, describes monitor‑based synchronization, lock optimizations such as biased and lightweight locks, introduces CAS and the AbstractQueuedSynchronizer framework, and provides practical code examples and usage scenarios.

CASJavaLocks
0 likes · 13 min read
Understanding Java Locks, Synchronization, and Concurrency Mechanisms
Java Captain
Java Captain
Feb 27, 2019 · Fundamentals

Understanding Java volatile: Memory Visibility, Ordering, and Interview Insights

This article explains the Java volatile keyword, covering its memory‑visibility and ordering guarantees, how it interacts with the Java Memory Model, why it does not ensure atomicity, and demonstrates typical interview‑style examples and code snippets such as flag signaling and double‑checked locking.

JavaMemory Modelatomicity
0 likes · 16 min read
Understanding Java volatile: Memory Visibility, Ordering, and Interview Insights
Big Data Technology & Architecture
Big Data Technology & Architecture
Feb 14, 2019 · Fundamentals

Understanding Java volatile: Memory Visibility, Lock Prefix, and Happens‑Before

This article explains the Java volatile keyword, covering its lightweight synchronization semantics, the underlying lock‑prefix implementation that forces cache line write‑backs, practical usage patterns such as state flags and double‑checked locking, and how volatile establishes a happens‑before relationship to guarantee memory visibility across threads.

Happens-beforeJVMJava
0 likes · 10 min read
Understanding Java volatile: Memory Visibility, Lock Prefix, and Happens‑Before
Programmer DD
Programmer DD
Jun 6, 2018 · Fundamentals

Why Double‑Checked Locking Fails in Java and How to Fix It

This article explains why the classic Double‑Checked Locking implementation of a lazy singleton is unsafe in Java, analyzes the underlying object‑creation reordering problem, and presents two reliable solutions—using a volatile field or a static holder class—to achieve thread‑safe lazy initialization.

JavaSingletonconcurrency
0 likes · 7 min read
Why Double‑Checked Locking Fails in Java and How to Fix It
Programmer DD
Programmer DD
Jun 5, 2018 · Fundamentals

How Volatile Enforces Memory Visibility and Prevents Reordering in Java

This article explains the Java volatile keyword by linking its visibility guarantees and happens‑before ordering to the underlying memory‑barrier implementation, illustrating the concepts with code examples, barrier diagrams, and a discussion of possible optimizations.

Javamemory barriersvolatile
0 likes · 8 min read
How Volatile Enforces Memory Visibility and Prevents Reordering in Java
21CTO
21CTO
May 9, 2018 · Backend Development

Why Use Locks? Deep Dive into Java Synchronization, Volatile, and AQS

This article explains why locks are needed in concurrent programming, explores the fundamentals of volatile and synchronized, details monitor mechanisms, lock optimizations like biased and lightweight locks, compares CAS and AQS, and illustrates Java lock implementations with diagrams and code examples.

AQSCASJava
0 likes · 11 min read
Why Use Locks? Deep Dive into Java Synchronization, Volatile, and AQS
Java Captain
Java Captain
May 8, 2018 · Fundamentals

Understanding Java Locks: volatile, synchronized, Monitor, CAS, and AQS

This article explains why locks are needed in Java, describes the fundamentals of volatile and synchronized, details monitor-based synchronization, explores lock optimizations such as biased and lightweight locks, and covers CAS and the AbstractQueuedSynchronizer framework for building concurrent structures.

AQSCASJava
0 likes · 12 min read
Understanding Java Locks: volatile, synchronized, Monitor, CAS, and AQS
Java Backend Technology
Java Backend Technology
Apr 17, 2018 · Backend Development

Mastering the Singleton Pattern in Java: Eager, Lazy, and Thread‑Safe Implementations

This article explains the concept of design patterns and dives deep into the Singleton pattern in Java, covering its purpose, eager and lazy implementations, thread‑safety challenges, double‑checked locking, volatile usage, static inner class, and enum approaches, while illustrating each with clear code examples and diagrams.

Double-Check LockingJavaSingleton
0 likes · 11 min read
Mastering the Singleton Pattern in Java: Eager, Lazy, and Thread‑Safe Implementations
Programmer DD
Programmer DD
Dec 6, 2017 · Fundamentals

Mastering Java Singleton: From Lazy Initialization to Enum with Thread‑Safety

This article walks through multiple Java Singleton implementations—lazy initialization, double‑checked locking, volatile‑protected, static‑inner‑class, and enum—explaining their thread‑safety characteristics, the pitfalls of instruction reordering, and how reflection and serialization can break or preserve the pattern.

JavaSingletondesign pattern
0 likes · 10 min read
Mastering Java Singleton: From Lazy Initialization to Enum with Thread‑Safety
ZhiKe AI
ZhiKe AI
Feb 23, 2017 · Fundamentals

Why volatile Is Not Thread‑Safe: A Java Increment Test

The article presents a Java program where 100 threads each increment a volatile int 1,000 times, showing that the final value may be less than the expected 100,000, and explains that volatile only guarantees visibility, not atomicity, making it unsuitable for concurrent modifications.

Javaatomicityconcurrency
0 likes · 2 min read
Why volatile Is Not Thread‑Safe: A Java Increment Test
Qunar Tech Salon
Qunar Tech Salon
Jul 14, 2015 · Fundamentals

Understanding Java volatile: Principles, Usage, and Best Practices

This article explains the Java volatile keyword, covering its definition, lightweight nature compared to synchronized, visibility guarantees, usage conditions, and practical patterns such as state flags, safe publication, volatile beans, and low‑cost read‑write lock strategies, illustrated with code examples.

JavaMemory Modelconcurrency
0 likes · 9 min read
Understanding Java volatile: Principles, Usage, and Best Practices