Tagged articles

Lock Ordering

2 articles · Page 1 of 1
Dabaoshi
Dabaoshi
Aug 17, 2026 · Fundamentals

Concurrency 07: Understanding Deadlocks and Thread‑Safety Strategies

This article explains how deadlocks arise from four necessary conditions, shows how to detect them with jstack, outlines practical ways to prevent deadlock, distinguishes livelock and starvation, and presents three prioritized approaches—immutability, thread confinement, and synchronization—to achieve thread safety in Java.

ConcurrencyImmutableJava
0 likes · 16 min read
Concurrency 07: Understanding Deadlocks and Thread‑Safety Strategies
Cognitive Technology Team
Cognitive Technology Team
May 3, 2023 · Backend Development

Avoiding Deadlocks with Lock Ordering and TryLock in Java

This article explains how deadlocks can occur in concurrent transfer scenarios, demonstrates their detection using jstack, and presents two prevention strategies—consistent lock ordering and attempting to acquire all locks with tryLock—while emphasizing the need for distributed locks in real-world systems.

JavaLock OrderingtryLock
0 likes · 4 min read
Avoiding Deadlocks with Lock Ordering and TryLock in Java