Tag

ReentrantLock

1 views collected around this technical thread.

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.

AQSFair LockJUC
0 likes · 19 min read
Deep Dive into ReentrantLock: Fair Lock vs Non-Fair Lock Implementation Principles
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.

ConcurrencyFairLockJava
0 likes · 23 min read
Understanding Fair and Unfair Locks in Java's ReentrantLock
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.

Backend DevelopmentConcurrencyJava
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.

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

AQSBackend DevelopmentConcurrency
0 likes · 12 min read
Understanding Java's AbstractQueuedSynchronizer (AQS) and ReentrantLock Implementation
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.

ConcurrencyConditionJUC
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.

AtomicJavaReentrantLock
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.

AQSConcurrencyJava
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.

ConcurrencyJVMJava
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.

ConcurrencyJVMJava
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.

ConcurrencyJVMJava
0 likes · 16 min read
Understanding Java synchronized and Lock Mechanisms: From Basic Locks to Advanced Optimizations
IT Architects Alliance
IT Architects Alliance
Jul 19, 2022 · Fundamentals

Understanding CAS, AQS, and Fair vs Non‑Fair Locks in Java

This article explains the principles of CAS, the ABA problem, and how Java's AbstractQueuedSynchronizer underpins ReentrantLock, comparing fair and non‑fair lock implementations, with code examples and discussion of their performance trade‑offs in.

AQSCASFair Lock
0 likes · 8 min read
Understanding CAS, AQS, and Fair vs Non‑Fair Locks in Java
Top Architect
Top Architect
Jul 17, 2022 · Backend Development

Understanding CAS, ABA Problem, and AQS in Java Concurrency: Fair vs Non‑Fair Locks

This article explains the fundamentals of CAS (compare‑and‑swap), the ABA problem and its version‑stamp solution, introduces AbstractQueuedSynchronizer (AQS) as the core of Java concurrency utilities, and compares fair and non‑fair lock implementations in ReentrantLock with code examples and diagrams.

ABAAQSCAS
0 likes · 9 min read
Understanding CAS, ABA Problem, and AQS in Java Concurrency: Fair vs Non‑Fair Locks
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.

AndroidConcurrencyFutex
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.

ConcurrencyGoJava
0 likes · 5 min read
Implementing Go's sync.Once Behavior in Java Using ReentrantLock
Selected Java Interview Questions
Selected Java Interview Questions
Apr 8, 2022 · Backend Development

Understanding ReentrantLock and AQS: A Deep Dive into Java Lock Implementation

This article provides a comprehensive walkthrough of Java's ReentrantLock implementation, covering linked list and queue data structures, the AbstractQueuedSynchronizer (AQS) framework, lock acquisition and release mechanisms, fair vs. non-fair locks, and detailed code analysis with illustrative diagrams.

AQSConcurrencyData Structures
0 likes · 27 min read
Understanding ReentrantLock and AQS: A Deep Dive into Java Lock Implementation
Sanyou's Java Diary
Sanyou's Java Diary
Mar 28, 2022 · Backend Development

Inside Java’s ReentrantLock: How AQS Powers Lock Acquisition and Release

This article explains how Java’s ReentrantLock relies on the AbstractQueuedSynchronizer (AQS) to manage lock state and a FIFO wait queue, detailing the step‑by‑step acquisition process with CAS, node insertion, parking, and the release mechanism that unparks successors.

AQSConcurrencyJava
0 likes · 9 min read
Inside Java’s ReentrantLock: How AQS Powers Lock Acquisition and Release
IT Services Circle
IT Services Circle
Mar 27, 2022 · Fundamentals

Differences Between ReentrantLock and synchronized in Java: An Interview‑Style Explanation

This article explains the key differences between Java's ReentrantLock and synchronized, covering fairness, tryLock, timeout, interruptibility, condition support, underlying implementations, and usage examples with code snippets, presented as an interview dialogue for candidates.

ConcurrencyInterviewJava
0 likes · 10 min read
Differences Between ReentrantLock and synchronized in Java: An Interview‑Style Explanation
政采云技术
政采云技术
Feb 17, 2022 · Backend Development

Comprehensive Guide to Java Locks: Synchronized, ReentrantLock, AQS, and Distributed Locks

This article provides an in‑depth overview of Java locking mechanisms, covering lock classifications, the inner workings of the synchronized keyword, ReentrantLock, AbstractQueuedSynchronizer, various lock optimizations, and practical implementations of distributed locks using Redis and Zookeeper.

AQSConcurrencyDistributedLock
0 likes · 28 min read
Comprehensive Guide to Java Locks: Synchronized, ReentrantLock, AQS, and Distributed Locks