Tagged articles
66 articles
Page 1 of 1
Tech Freedom Circle
Tech Freedom Circle
Jan 27, 2026 · Interview Experience

Netease Interview: Write a BlockingQueue in 5 Minutes and Explain Design Patterns & Principles

The article breaks down a common Netease interview task—hand‑coding a BlockingQueue in five minutes—by explaining the underlying lock‑and‑condition mechanism, the relevant design patterns and principles, common pitfalls such as spurious wakeups, and provides a concise, 50‑line Java implementation with step‑by‑step commentary.

BlockingQueueDesign PatternsInterview Preparation
0 likes · 20 min read
Netease Interview: Write a BlockingQueue in 5 Minutes and Explain Design Patterns & Principles
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Oct 18, 2025 · Backend Development

Master Java Concurrency: Choose ReentrantLock, ReadWriteLock, StampedLock, or Semaphore

This article explores Java’s advanced lock mechanisms—ReentrantLock, ReentrantReadWriteLock, StampedLock, and Semaphore—detailing their core features, practical code examples, and ideal usage scenarios, helping developers decide which synchronization tool best fits their performance and concurrency requirements.

LocksReadWriteLockReentrantLock
0 likes · 9 min read
Master Java Concurrency: Choose ReentrantLock, ReadWriteLock, StampedLock, or Semaphore
Cognitive Technology Team
Cognitive Technology Team
Aug 17, 2025 · Backend Development

synchronized vs Lock in Java: When to Choose Each for Thread Safety

This article examines the core differences between Java's synchronized keyword and the Lock interface, covering their principles, performance, flexibility, visibility guarantees, reentrancy, interruption handling, and practical selection guidelines with code examples, tables, and real‑world scenarios to help developers choose the appropriate locking mechanism.

LockReentrantLockjava
0 likes · 9 min read
synchronized vs Lock in Java: When to Choose Each for Thread Safety
The Dominant Programmer
The Dominant Programmer
Jul 9, 2025 · Backend Development

Understanding Java Concurrency Locks: synchronized, ReentrantLock, ReadWriteLock, and StampedLock

This article explains Java 8's built‑in lock mechanisms—including synchronized, ReentrantLock, ReadWriteLock, and StampedLock—detailing their characteristics, advanced features, and practical usage through inventory, banking, and order‑processing examples with complete code demonstrations.

ConditionLocksReadWriteLock
0 likes · 22 min read
Understanding Java Concurrency Locks: synchronized, ReentrantLock, ReadWriteLock, and StampedLock
Architect's Guide
Architect's Guide
Jun 27, 2025 · Backend Development

Demystifying Java Locks: From Pessimistic vs Optimistic to ReentrantLock Internals

This article explains the classification of Java locks—including pessimistic, optimistic, fair, and unfair variants—details their state transitions from biased to heavyweight, and walks through the source code of ReentrantLock and Condition to illustrate how synchronization, queuing, and thread parking are implemented in the JVM.

AQSConditionLocks
0 likes · 20 min read
Demystifying Java Locks: From Pessimistic vs Optimistic to ReentrantLock Internals
Architect's Must-Have
Architect's Must-Have
May 7, 2025 · Backend Development

How ReentrantLock Works: Inside Java’s AbstractQueuedSynchronizer

This article dissects Java’s ReentrantLock implementation, detailing its delegation to AbstractQueuedSynchronizer, the lock acquisition process, the role of non‑fair and fair sync subclasses, the internal CLH queue mechanics, and how unlocking is handled, while comparing Lock with synchronized.

AbstractQueuedSynchronizerLockReentrantLock
0 likes · 14 min read
How ReentrantLock Works: Inside Java’s AbstractQueuedSynchronizer
Sohu Tech Products
Sohu Tech Products
Apr 29, 2025 · Backend Development

Mastering Java Concurrency: Deep Dive into Threads, Locks, and AQS

This comprehensive guide explores Java multithreading fundamentals, covering thread creation, lifecycle, synchronization challenges, context switching costs, deadlock detection, various lock mechanisms such as synchronized, ReentrantLock, ReadWriteLock, and the underlying AbstractQueuedSynchronizer architecture with practical code examples and performance tips.

AQSConditionLocks
0 likes · 42 min read
Mastering Java Concurrency: Deep Dive into Threads, Locks, and AQS
Sohu Tech Products
Sohu Tech Products
Feb 19, 2025 · Fundamentals

Deep Dive into ReentrantLock: Fair Lock vs Non-Fair Lock Implementation Principles

The article explains Java’s ReentrantLock implementation, contrasting fair locks that queue threads in request order with non‑fair locks that allow immediate acquisition, detailing the internal Sync, FairSync and NonfairSync classes, lock/unlock mechanisms, performance trade‑offs, and guidance on selecting the appropriate lock type.

AQSJUCJava concurrency
0 likes · 19 min read
Deep Dive into ReentrantLock: Fair Lock vs Non-Fair Lock Implementation Principles
Xuanwu Backend Tech Stack
Xuanwu Backend Tech Stack
Jan 17, 2025 · Backend Development

Why Reentrant Locks Prevent Deadlocks and How to Use Them in Java

Reentrant locks are thread‑safe synchronization tools that let the same thread acquire the same lock multiple times without deadlocking, tracking acquisition counts, and offering advantages over traditional synchronized blocks, with Java’s ReentrantLock providing flexible features such as interruptible and timed locking, illustrated by a complete code example.

ReentrantLockconcurrencyjava
0 likes · 6 min read
Why Reentrant Locks Prevent Deadlocks and How to Use Them in Java
Senior Tony
Senior Tony
Jan 13, 2025 · Backend Development

How Java’s AQS Powers ReentrantLock – A Deep Dive into the Source

This article explains the core concepts of Java’s AbstractQueuedSynchronizer (AQS), its exclusive and shared modes, the template‑method design it uses, and walks through the actual source code showing how ReentrantLock implements both fair and non‑fair locking, complete with diagrams and code snippets for interview preparation.

AQSLockReentrantLock
0 likes · 10 min read
How Java’s AQS Powers ReentrantLock – A Deep Dive into the Source
FunTester
FunTester
Dec 31, 2024 · Backend Development

Mastering Java ReentrantLock: Blocking, Interruptible, and Timeout Locks Explained

This article explains the Java java.util.concurrent.locks.Lock interface and its ReentrantLock implementation, detailing the advantages of reentrancy, interruptibility, and timeout features, and provides practical code examples for blocking, interruptible, and timed lock acquisition along with best‑practice recommendations.

LockReentrantLockconcurrency
0 likes · 12 min read
Mastering Java ReentrantLock: Blocking, Interruptible, and Timeout Locks Explained
Zhuanzhuan Tech
Zhuanzhuan Tech
Dec 2, 2024 · Fundamentals

Understanding Fair and Unfair Locks in Java's ReentrantLock

This article explains the concepts, creation methods, usage examples, and internal implementation details of fair and unfair locks in Java's ReentrantLock, comparing their performance characteristics and providing guidance on when to choose each type in multithreaded applications.

FairLockReentrantLockconcurrency
0 likes · 23 min read
Understanding Fair and Unfair Locks in Java's ReentrantLock
Architect's Guide
Architect's Guide
Dec 26, 2023 · Fundamentals

Java Thread Communication Techniques: volatile, wait/notify, CountDownLatch, ReentrantLock with Condition, and LockSupport

This article demonstrates five Java thread‑communication approaches—using a volatile flag, Object.wait()/notify(), CountDownLatch, ReentrantLock with Condition, and LockSupport—each illustrated with complete code examples and explanations of their behavior and limitations.

CountDownLatchLockSupportReentrantLock
0 likes · 10 min read
Java Thread Communication Techniques: volatile, wait/notify, CountDownLatch, ReentrantLock with Condition, and LockSupport
FunTester
FunTester
Oct 26, 2023 · Fundamentals

Mastering Java Locks: Reentrant, Synchronized, ReadWrite, and Spin Locks Explained

This article provides a comprehensive guide to Java locking mechanisms, covering ReentrantLock, synchronized, ReadWriteLock, and spin locks, with detailed code examples, performance considerations, common use cases, and best practices to ensure thread safety, avoid deadlocks, and optimize concurrency in multithreaded applications.

LocksReadWriteLockReentrantLock
0 likes · 17 min read
Mastering Java Locks: Reentrant, Synchronized, ReadWrite, and Spin Locks Explained
FunTester
FunTester
Oct 24, 2023 · Backend Development

Using java.util.concurrent.locks.ReentrantLock: Blocking, Interruptible, and Timed Locks in Java

This article explains thread safety in Java multithreading, introduces the ReentrantLock class from java.util.concurrent.locks, demonstrates blocking, interruptible, and timed lock usage with code examples, discusses best practices, fairness, reentrancy, and performance considerations for effective concurrency control.

ReentrantLockconcurrencyjava
0 likes · 8 min read
Using java.util.concurrent.locks.ReentrantLock: Blocking, Interruptible, and Timed Locks 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.

CountDownLatchLockSupportReentrantLock
0 likes · 11 min read
Thread Communication in Java: volatile, wait/notify, CountDownLatch, ReentrantLock+Condition, and LockSupport
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.

CountDownLatchLockSupportReentrantLock
0 likes · 13 min read
5 Practical Ways to Implement Thread Communication in Java
HelloTech
HelloTech
Jul 28, 2023 · Backend Development

Understanding Java's AbstractQueuedSynchronizer (AQS) and ReentrantLock Implementation

The article explains Java’s AbstractQueuedSynchronizer framework and how ReentrantLock uses its inner Sync classes—FairSync and NonfairSync—to manage lock acquisition via CAS, queueing, spinning, and parking, detailing the acquire/release loops, fair vs non‑fair behavior, and interview‑ready insights.

AQSLockReentrantLock
0 likes · 12 min read
Understanding Java's AbstractQueuedSynchronizer (AQS) and ReentrantLock Implementation
Su San Talks Tech
Su San Talks Tech
Jun 27, 2023 · Backend Development

Unveiling ThreadPoolExecutor’s Hidden Locks: Why mainLock and Worker Locks Matter

This article delves into the often‑overlooked locking mechanisms inside Java’s ThreadPoolExecutor, explaining the purpose of the mainLock ReentrantLock, the worker‑level lock, and how they prevent interrupt storms, ensure accurate statistics, and coordinate thread‑safe access to internal data structures.

LocksReentrantLockThreadPoolExecutor
0 likes · 14 min read
Unveiling ThreadPoolExecutor’s Hidden Locks: Why mainLock and Worker Locks Matter
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Nov 30, 2022 · Backend Development

Understanding Java J.U.C Locks: ReentrantLock, ReentrantReadWriteLock, and Condition

This article introduces Java's java.util.concurrent (J.U.C) package, explains its lock mechanisms—including Lock, ReentrantLock, ReentrantReadWriteLock, and Condition—provides detailed code examples, and discusses lock types such as fair, non‑fair, and read/write locks for effective multithreaded synchronization.

ConditionJUCLocks
0 likes · 16 min read
Understanding Java J.U.C Locks: ReentrantLock, ReentrantReadWriteLock, and Condition
Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Sep 27, 2022 · Backend Development

Four Common Ways to Implement Thread Synchronization in Java

This article explains the concept of thread synchronization in Java and provides detailed examples of four implementation methods—using the synchronized keyword, ReentrantLock, atomic variables, and ThreadLocal—along with code snippets and a comparison of their advantages and usage scenarios.

ReentrantLockThreadLocalatomic
0 likes · 6 min read
Four Common Ways to Implement Thread Synchronization in Java
IT Architects Alliance
IT Architects Alliance
Aug 27, 2022 · Backend Development

Understanding ReentrantLock and the AQS Framework in Java

This article explains how Java's ReentrantLock works, detailing the role of the AbstractQueuedSynchronizer framework, the lock's internal architecture, the FIFO wait‑queue implementation, lock acquisition and release processes, and how these mechanisms avoid the herd effect in multithreaded environments.

AQSReentrantLockSynchronization
0 likes · 11 min read
Understanding ReentrantLock and the AQS Framework in Java
Top Architect
Top Architect
Aug 26, 2022 · Backend Development

Deep Dive into Java synchronized and Lock Mechanisms: Principles, JVM Internals, and Optimizations

This article explains thread safety in Java by detailing how the synchronized keyword and various Lock implementations work, covering their underlying JVM mechanisms, lock upgrade paths, optimizations like biased and lightweight locks, and practical differences between synchronized, ReentrantLock, and ReadWriteLock.

JVMLockReadWriteLock
0 likes · 19 min read
Deep Dive into Java synchronized and Lock Mechanisms: Principles, JVM Internals, and Optimizations
Top Architect
Top Architect
Aug 23, 2022 · Backend Development

Understanding the Implementation of synchronized in Java and Its Differences with Lock

This article explains how Java's synchronized keyword works at the JVM level, detailing monitorenter/monitorexit bytecode, the role of object monitors, differences between synchronized methods and blocks, and compares its behavior and performance with explicit Lock implementations such as ReentrantLock, including code examples and practical considerations.

JVMLockReentrantLock
0 likes · 8 min read
Understanding the Implementation of synchronized in Java and Its Differences with Lock
Selected Java Interview Questions
Selected Java Interview Questions
Aug 22, 2022 · Backend Development

Understanding Java synchronized and Lock Mechanisms: From Basic Locks to Advanced Optimizations

This article explains Java thread‑safety concepts, the synchronized keyword, its underlying monitor implementation, lock‑upgrade stages, JVM optimizations such as lock elimination and coarsening, and compares explicit Lock interfaces like ReentrantLock and ReadWriteLock, helping developers choose the appropriate synchronization tool.

JVMLockReadWriteLock
0 likes · 16 min read
Understanding Java synchronized and Lock Mechanisms: From Basic Locks to Advanced Optimizations
OPPO Kernel Craftsman
OPPO Kernel Craftsman
Jul 15, 2022 · Mobile Development

Understanding User‑Space Locks on Android: Java, JUC, and Native Locks

The article explains Android’s user‑space locking hierarchy—from Java intrinsic and JUC locks to C++ std::mutex and pthread mutexes—detailing their internal structures, state transitions, and reliance on futex system calls for kernel‑level blocking, helping developers optimize synchronization across Java and native layers.

AndroidLocksReentrantLock
0 likes · 17 min read
Understanding User‑Space Locks on Android: Java, JUC, and Native Locks
FunTester
FunTester
Jun 22, 2022 · Backend Development

Implementing Go's sync.Once Behavior in Java Using ReentrantLock

This article explains the Go sync.Once primitive, demonstrates its one‑time execution with concurrent goroutines, and shows how to recreate the same functionality in Java by using a static collection and ReentrantLock to ensure a block of code runs only once across multiple threads.

ReentrantLockSingletonconcurrency
0 likes · 5 min read
Implementing Go's sync.Once Behavior in Java Using ReentrantLock
Selected Java Interview Questions
Selected Java Interview Questions
Jan 25, 2022 · Fundamentals

Understanding Java synchronized and ReentrantLock: When Multiple Threads Can Access Synchronized Methods

This article examines how Java's synchronized keyword and ReentrantLock behave when multiple threads invoke two synchronized methods of the same class, exploring scenarios with the same instance, different instances, and Runnable run methods, and summarizing the resulting concurrency rules.

ReentrantLockSynchronizationconcurrency
0 likes · 15 min read
Understanding Java synchronized and ReentrantLock: When Multiple Threads Can Access Synchronized Methods
JavaEdge
JavaEdge
Dec 11, 2021 · Backend Development

Master Java Locks: From Pessimistic to Optimistic and Beyond

This article explains the full spectrum of Java concurrency locks—including pessimistic, optimistic, exclusive, shared, fair, unfair, segment, reentrant, and spin locks—detailing their principles, typical use cases, implementation details, and code examples to help you ace interview questions.

CASLocksOptimisticLock
0 likes · 12 min read
Master Java Locks: From Pessimistic to Optimistic and Beyond
FunTester
FunTester
Nov 5, 2021 · Backend Development

Master Java ReentrantLock: Simple Thread‑Safe Coding Without synchronized

This article introduces Java's ReentrantLock as an easy-to‑use alternative to synchronized, explains its core lock() and unlock() methods, demonstrates practical code examples, and covers advanced APIs such as tryLock, getQueueLength, isLocked, and getHoldCount for robust multithreaded programming.

BackendReentrantLockconcurrency
0 likes · 5 min read
Master Java ReentrantLock: Simple Thread‑Safe Coding Without synchronized
Ops Development Stories
Ops Development Stories
Sep 13, 2021 · Backend Development

Mastering Java Locks: When to Use synchronized vs ReentrantLock

This article explains how Java locks solve concurrent access problems, compares the built‑in synchronized lock with ReentrantLock, describes their upgrade mechanisms, usage patterns, and scenarios, and offers guidance on choosing the appropriate lock for different environments.

LocksReentrantLockconcurrency
0 likes · 7 min read
Mastering Java Locks: When to Use synchronized vs ReentrantLock
JavaEdge
JavaEdge
Apr 27, 2021 · Backend Development

Why Does Java Provide Both synchronized and Lock? Uncover the Real Differences

This article explains the core concepts of Java concurrency, comparing mutual exclusion and synchronization, detailing how JUC's Lock and Condition implement monitors, why Lock offers interruptible, timed, and non‑blocking acquisition, and how visibility and reentrancy are guaranteed through volatile state and Happens‑Before rules.

JUCReentrantLockjava
0 likes · 9 min read
Why Does Java Provide Both synchronized and Lock? Uncover the Real Differences
Code Ape Tech Column
Code Ape Tech Column
Aug 22, 2020 · Fundamentals

How ReentrantLock Works Under the Hood: A Deep Dive into Java’s AQS

This article breaks down the inner workings of Java’s ReentrantLock, explaining spin locks, the role of AbstractQueuedSynchronizer, fair vs. non‑fair locking, and step‑by‑step thread execution with code examples and diagrams to illustrate the complete lock acquisition and release process.

AQSLockReentrantLock
0 likes · 17 min read
How ReentrantLock Works Under the Hood: A Deep Dive into Java’s AQS
Big Data Technology & Architecture
Big Data Technology & Architecture
Jul 8, 2020 · Fundamentals

Understanding Java Locks: Optimistic vs Pessimistic, Spin Locks, and ReentrantLock

This article explains the various types of locks provided by Java, compares optimistic and pessimistic locking, introduces spin locks and adaptive spin locks, details lock states such as biased, lightweight, and heavyweight, and examines fair versus non‑fair, reentrant versus non‑reentrant, and exclusive versus shared locks with source code references.

CASLocksReentrantLock
0 likes · 25 min read
Understanding Java Locks: Optimistic vs Pessimistic, Spin Locks, and ReentrantLock
Programmer DD
Programmer DD
Jun 8, 2020 · Fundamentals

Why Java Replaced synchronized with Lock and How AQS Powers Modern Concurrency

This article explains why Java introduced the Lock API after Java 1.5, compares it with synchronized, details the explicit lock features, walks through the AQS (AbstractQueuedSynchronizer) implementation, and shows how ReentrantLock, fairness, reentrancy, and conditions are built on top of AQS.

AQSLockReentrantLock
0 likes · 36 min read
Why Java Replaced synchronized with Lock and How AQS Powers Modern Concurrency
Selected Java Interview Questions
Selected Java Interview Questions
Apr 13, 2020 · Backend Development

Differences Between synchronized and Lock in Java with Code Examples

This article explains Java's thread synchronization mechanisms by comparing synchronized blocks with the Lock interface, detailing thread basics, lifecycle methods, lock types, code demonstrations, fairness settings, and underlying JVM implementations, helping readers understand when and how to use each construct effectively.

LockReentrantLockThread
0 likes · 17 min read
Differences Between synchronized and Lock in Java with Code Examples
Selected Java Interview Questions
Selected Java Interview Questions
Mar 4, 2020 · Backend Development

Classification and Explanation of Java Locks for Interview Preparation

This article summarizes the main types of Java locks—including fair/unfair, reentrant, exclusive/shared, mutex/read‑write, optimistic/pessimistic, segment, biased/lightweight/heavyweight, and spin locks—provides brief definitions, usage notes, and a code example to help interview candidates answer concurrency questions effectively.

LocksReentrantLockconcurrency
0 likes · 8 min read
Classification and Explanation of Java Locks for Interview Preparation
Qunar Tech Salon
Qunar Tech Salon
Feb 19, 2020 · Fundamentals

Deep Dive into Java's AbstractQueuedSynchronizer (AQS) and ReentrantLock

This article provides a comprehensive analysis of Java's AbstractQueuedSynchronizer (AQS) framework, explains how ReentrantLock is built on AQS, walks through lock acquisition and release mechanisms, discusses queue management, and demonstrates how to create a custom lock using AQS.

AQSLockReentrantLock
0 likes · 32 min read
Deep Dive into Java's AbstractQueuedSynchronizer (AQS) and ReentrantLock
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Feb 17, 2020 · Backend Development

Understanding JVM-Level Locks in Java: synchronized, ReentrantLock, ReentrantReadWriteLock, and LongAdder

This article explains the evolution and implementation of Java's JVM‑level locks—including synchronized, ReentrantLock, ReentrantReadWriteLock, and LongAdder—detailing their lock‑upgrade process, internal object layout, AQS‑based algorithms, and how they improve concurrency and performance in multithreaded applications.

LocksReadWriteLockReentrantLock
0 likes · 24 min read
Understanding JVM-Level Locks in Java: synchronized, ReentrantLock, ReentrantReadWriteLock, and LongAdder
Java Interview Crash Guide
Java Interview Crash Guide
Feb 13, 2020 · Backend Development

Java Concurrency Locks Explained: From Synchronized to ReentrantReadWriteLock

This article provides a comprehensive overview of Java concurrency locks, covering classifications such as optimistic, pessimistic, fair, unfair, reentrant, exclusive/shared, spin, and segmented locks, as well as detailed explanations of synchronized, ReentrantLock, and ReadWriteLock usage with code examples.

LocksReadWriteLockReentrantLock
0 likes · 21 min read
Java Concurrency Locks Explained: From Synchronized to ReentrantReadWriteLock
Meituan Technology Team
Meituan Technology Team
Dec 5, 2019 · Backend Development

Understanding AbstractQueuedSynchronizer (AQS) and ReentrantLock in Java

The article explains Java’s AbstractQueuedSynchronizer as the foundation of many concurrency utilities, details how ReentrantLock leverages AQS’s FIFO CLH queue, state field, and lock acquisition/release mechanisms, compares it with synchronized, and demonstrates building a custom lock with AQS.

AQSReentrantLockSynchronization
0 likes · 33 min read
Understanding AbstractQueuedSynchronizer (AQS) and ReentrantLock in Java
Big Data Technology & Architecture
Big Data Technology & Architecture
Feb 14, 2019 · Fundamentals

Java Lock Types and Their Implementation Details

This article provides a comprehensive overview of various Java lock mechanisms—including fair, non‑fair, reentrant, read/write, biased, lightweight, heavyweight, and spin locks—explaining their classifications, usage, underlying AQS implementation, and includes illustrative code snippets for each type.

AQSLocksReadWriteLock
0 likes · 22 min read
Java Lock Types and Their Implementation Details
Java Captain
Java Captain
Jan 26, 2019 · Fundamentals

Classification and Implementation of Various Java Locks

This article explains the different types of Java locks—including fair, reentrant, exclusive, read‑write, optimistic, pessimistic, segment, biased, lightweight, heavyweight, and spin locks—describes their characteristics, usage scenarios, and provides concrete code examples for each implementation.

AQSReentrantLockSpinlock
0 likes · 15 min read
Classification and Implementation of Various Java Locks
Meituan Technology Team
Meituan Technology Team
Nov 15, 2018 · Backend Development

Understanding Java Locks: Optimistic, Pessimistic, CAS, and Various Lock Types

The article explains Java’s various lock mechanisms—including optimistic vs. pessimistic, spin and adaptive spin, no‑lock through heavyweight states, fair vs. unfair, reentrant vs. non‑reentrant, and exclusive vs. shared locks—using JDK 8 source code and practical examples to guide developers in choosing the appropriate lock for different concurrency scenarios.

CASLocksReadWriteLock
0 likes · 26 min read
Understanding Java Locks: Optimistic, Pessimistic, CAS, and Various Lock Types
Programmer DD
Programmer DD
Jul 23, 2018 · Fundamentals

How Does Java’s ArrayBlockingQueue Work Under the Hood?

This article explains the internal design of Java’s ArrayBlockingQueue—a fixed‑size, FIFO blocking queue that uses a ReentrantLock and Condition objects to coordinate producers and consumers, detailing its fields, fairness option, and the concrete implementations of add, offer, poll, and take methods.

ArrayBlockingQueueBlockingQueueReentrantLock
0 likes · 10 min read
How Does Java’s ArrayBlockingQueue Work Under the Hood?
Java Backend Technology
Java Backend Technology
Nov 1, 2017 · Backend Development

Mastering ReentrantReadWriteLock: Deep Dive into Java’s Read‑Write Lock Mechanics

This article explains the structure, features, and internal workings of Java's ReentrantReadWriteLock, compares it with ReentrantLock and synchronized, provides usage examples, analyzes state management with bitwise operations, and covers lock acquisition, release, downgrade, and the role of LockSupport.

LockSupportReadWriteLockReentrantLock
0 likes · 10 min read
Mastering ReentrantReadWriteLock: Deep Dive into Java’s Read‑Write Lock Mechanics
Java Backend Technology
Java Backend Technology
Sep 16, 2017 · Backend Development

Mastering Java’s Synchronized Reentrant Lock: Features, Pitfalls, and Best Practices

This article explains Java’s synchronized keyword’s reentrant lock capability, demonstrates how nested synchronized methods acquire the same lock without deadlock, explores additional features such as automatic lock release on exceptions, using arbitrary objects as monitors, and illustrates the double‑checked locking pattern for singleton implementation.

ReentrantLockconcurrencyjava
0 likes · 5 min read
Mastering Java’s Synchronized Reentrant Lock: Features, Pitfalls, and Best Practices
BiCaiJia Technology Team
BiCaiJia Technology Team
Sep 9, 2017 · Backend Development

Mastering Java Concurrency: ReentrantLock, Condition, and ReadWriteLock Explained

This article demonstrates how to use Java's ReentrantLock, Condition, and ReentrantReadWriteLock classes to implement synchronization, waiting/notification, producer‑consumer patterns, and read‑write locking, providing code examples, execution results, and tips for avoiding deadlocks and improving thread coordination.

ConditionReadWriteLockReentrantLock
0 likes · 17 min read
Mastering Java Concurrency: ReentrantLock, Condition, and ReadWriteLock Explained