Deadlock
A deadlock is a state in concurrent execution where two or more activities are indefinitely blocked by dependencies on resources, events, or progress that cannot become available.
C++ Concurrency in Action, Second Edition
Deadlock is a state in which two or more threads are indefinitely blocked, each waiting for a resource or event that another blocked thread must provide.
- How it is used
- Identifies a progress failure introduced when shared-data operations require multiple mutexes.
- How deep it goes
- Works through a two-mutex swap and gives lock-order guidelines and a hierarchy-enforcement example.
- Examples
- Uses a reversed-argument swap, mutual thread joining, and a hierarchical mutex that rejects lock-order violations.
- What you can do after
- Apply it via std::lock or std::scoped_lock to acquire both locks for a two-object swap.
Read how C++ Concurrency in Action, Second Edition explains deadlock →
Troubleshooting Java, Second Edition
A deadlock is a concurrency failure in which threads or transactions wait indefinitely for locks or resources held by one another.
- How it is used
- Diagnoses frozen or unresponsive concurrent applications by tracing reciprocal waits among threads and locks.
- How deep it goes
- Explains monitor-order failures and thread-dump cycle tracing, but defers execution dynamics to profiling.
- Examples
- Uses Consumer and Producer threads, two shared lists, reversed monitor order, and reciprocal BLOCKED thread-dump entries.
- What you can do after
- Diagnose deadlocks with VisualVM or JDK command-line thread dumps by tracing blocked threads, lock IDs, owners, and cycles.
Read how Troubleshooting Java, Second Edition explains deadlock →
Learn Concurrent Programming with Go
A deadlock is a state in which two or more executions wait indefinitely for conditions that can be satisfied only by one another.
- How it is used
- Frames failures in concurrent programs that acquire multiple exclusive resources or wait on channel operations.
- How deep it goes
- Defines deadlock, traces mutex and ledger cycles, and develops safe allocation plus a condition-variable arbitrator.
- Examples
- Uses opposing mutex acquisitions, bank-account transfers, rail crossings, player scores, and channel send-receive exercises.
- What you can do after
- Apply it via sync.Cond arbitration to coordinate multi-account transfers without holding one account while awaiting another.
Read how Learn Concurrent Programming with Go explains deadlock →
Functional Programming in Scala, Second Edition
A deadlock is a state in which concurrent computations wait indefinitely for one another to release resources or provide progress.
- How it is used
- Diagnoses unsafe implementations of fork and parallel combinators under bounded thread-pool execution.
- How deep it goes
- Explains the worker-exhaustion mechanism and generalizes it to nested forks, but does not develop a complete prevention strategy.
- Examples
- Uses a one-thread fixed pool, a forked computation, and nested expressions such as fork(fork(fork(x))).
- What you can do after
- Diagnose/debug with it by tracing blocked workers and queued computations in bounded executors.
Read how Functional Programming in Scala, Second Edition explains deadlock →
C# Concurrency: Asynchronous and multithreaded programming
A deadlock is a program state in which two or more execution flows remain stuck because each is waiting for progress that cannot occur.
- How it is used
- Diagnoses a central multithreading failure mode and supplies practical rules for preventing indefinite waiting.
- How deep it goes
- Explains mutex cycles, self-waiting, resource behavior, callbacks, thread control, and asynchronous blocking hazards.
- Examples
- Uses two mutexes, opposing lock orders, divide-by-zero callbacks, thread suspension, and an asynchronous camera operation.
- What you can do after
- Diagnose deadlock cycles, enforce lock hierarchies, move callbacks outside locks, and preserve asynchronous control flow with await.
Read how C# Concurrency: Asynchronous and multithreaded programming explains deadlock →
Python Concurrency with asyncio
A deadlock is a state in which concurrent execution cannot progress because each participant waits indefinitely for a resource held by another participant or for an unreleased resource.
- How it is used
- Explains why threaded applications and asynchronous subprocesses can hang indefinitely when resource dependencies form a cycle.
- How deep it goes
- Works through lock-order and pipe-buffer mechanisms with runnable examples, while stopping short of formal deadlock conditions.
- Examples
- Demonstrates opposing lock orders, a million-line subprocess output, concurrent stream consumption, and communicate().
- What you can do after
- Diagnose hangs by tracing circular lock ownership or unconsumed pipe output, then apply reentrant locks or communicate() where appropriate.
Read how Python Concurrency with asyncio explains deadlock →
100 Go Mistakes and How to Avoid Them
A deadlock is a state in which concurrent executions are permanently blocked because each is waiting for an event or resource that cannot become available.
- How it is used
- Diagnoses concurrency mistakes involving mutexes, channels, indirect calls, and goroutine scheduling.
- How deep it goes
- Traces a mutex deadlock through formatting and compares lock-scope and direct-formatting fixes, while treating channel deadlocks more briefly.
- Examples
- Uses a Customer.UpdateAge and String interaction, a runtime deadlock panic, and buffered-versus-unbuffered channel behavior.
- What you can do after
- Diagnose deadlocks by tracing lock ownership and indirect calls, then reduce lock scope or remove mutex acquisition from formatting.
Read how 100 Go Mistakes and How to Avoid Them explains deadlock →
Learn Go with Pocket-Sized Projects
A deadlock is a concurrency failure in which execution cannot make progress because goroutines remain blocked waiting for events that cannot occur.
- How it is used
- Diagnoses blocked communication and coordinates shutdown in a concurrent maze solver.
- How deep it goes
- Explains blocking sends, channel capacity, shutdown races, closed-channel broadcasts, cancellation selects, and worker waiting.
- Examples
- Uses a concurrent maze solver, blocked path publication, treasure discovery, quit signaling, and worker cancellation.
- What you can do after
- Diagnose deadlocks by tracing blocked channel operations and apply coordinated cancellation to stop workers safely.
Read how Learn Go with Pocket-Sized Projects explains deadlock →
Java Persistence with Spring Data and Hibernate epub
A deadlock is a cyclic waiting condition in which concurrent transactions each hold locks needed by another and none can proceed.
- How it is used
- Explains transaction failures caused by conflicting database locks during concurrent persistence operations.
- How deep it goes
- Traces opposing row-update orders through Hibernate flushes and compares isolation, exclusive locks, and ordered updates.
- Examples
- Uses two Item entities, opposing SQL UPDATE orders, exclusive locks, serializable isolation, and production transaction load.
- What you can do after
- Diagnose/debug with it by recognizing conflicting update order and configure Hibernate to order updates consistently.
Read how Java Persistence with Spring Data and Hibernate epub explains deadlock →
Distributed Machine Learning Patterns
A deadlock is a state in which a set of tasks cannot proceed because each is waiting for resources or progress that cannot become available.
- How it is used
- Prevents workflow stalls by guiding job scheduling and distributed worker coordination.
- How deep it goes
- Explains a queued-job failure scenario and mitigation through priority, preemption, and gang scheduling.
- Examples
- Uses a stuck database-producing job, a queued restart job, and distributed gradient exchange blocked by an unstable network.
- What you can do after
- Diagnose/debug with it by recognizing blocked recovery work and selecting priority, preemption, or gang scheduling.
Read how Distributed Machine Learning Patterns explains deadlock →
Grokking Concurrency
A deadlock is a concurrency state in which multiple tasks wait indefinitely for resources held by one another, preventing all of them from continuing.
- How it is used
- Diagnoses a concurrency failure in which tasks permanently wait on resources held by one another.
- How deep it goes
- Explains the failure through a two-lock philosopher example and introduces lock ordering, graphs, hierarchies, and timeouts.
- Examples
- Uses two philosophers, two chopsticks, dumplings, Python locks, and opposing resource-acquisition orders.
- What you can do after
- Diagnose deadlock-prone lock acquisition and apply a consistent resource hierarchy to avoid it.
Advanced Algorithms and Data Structures
A deadlock is a state in which concurrent execution cannot proceed because threads wait indefinitely for resources held by one another or for unreleased locks.
- How it is used
- Protects concurrent cache implementations from indefinite blocking caused by unreleased or recursively acquired locks.
- How deep it goes
- Explains lock waiting, failure-safe release, and nested non-reentrant acquisition, but does not develop general deadlock detection.
- Examples
- Uses concurrent LRU and LFU cache methods, especially set calling evictOneEntry while holding a write lock.
- What you can do after
- Diagnose lock-release and nested-acquisition hazards when designing synchronized cache operations.
Read how Advanced Algorithms and Data Structures explains deadlock →
Modern C, Third Edition
A deadlock is a condition in which multiple execution entities are permanently blocked because each depends on a resource or action held up by another in a cycle.
- How it is used
- Diagnoses blocked multithreaded executions caused by cyclic resource dependencies.
- How deep it goes
- Explains cyclic mutex waits and avoidance rules, while deferring comprehensive deadlock proofs.
- Examples
- Uses a congested roundabout and two threads that acquire mutexes in opposite orders.
- What you can do after
- Diagnose mutex cycles and apply consistent locking order or timed condition waits to reduce blocking risks.
Software Design for Python Programmers
A deadlock is a concurrency failure in which threads remain blocked because each is waiting for a resource or synchronization action that cannot become available.
- How it is used
- Uses deadlock to identify a multithreading failure that complicates debugging and can halt an application.
- How deep it goes
- Defines the failure and demonstrates one prevention technique, but does not develop broader deadlock-detection algorithms.
- Examples
- Uses shared printing, mutex-protected critical regions, explicit release, and Python’s with statement.
- What you can do after
- Diagnose hangs caused by unreleased synchronization objects and prevent them with automatic mutex management.
Read how Software Design for Python Programmers explains deadlock →
Learn Rust in a Month of Lunches
A deadlock is a state in which threads or operations wait indefinitely for access held by one another.
- How it is used
- Uses lock ownership and guard lifetimes to explain why concurrent Rust code can wait indefinitely.
- How deep it goes
- Explains the waiting mechanism, demonstrates repeated locking, and gives scope, drop(), and try-method remedies.
- Examples
- Shows repeated Mutex locking, scoped guards, drop(), try_lock(), and RwLock read-then-write access.
- What you can do after
- Diagnose/debug with it by identifying held guards and prevent indefinite waits with scopes, drop(), or try-lock methods.
Read how Learn Rust in a Month of Lunches explains deadlock →
Related concepts
- race conditioncontrasts with · A race condition is a concurrency defect in which program behavior or results depend on the relative timing or ordering of interacting operations.
- std::lockaddressed by · `std::lock` is a C++ standard library function template that locks multiple lockable objects together while avoiding deadlock among those objects.
- lock hierarchyaddressed by · Lock hierarchy is a synchronization rule that requires locks to be acquired in a consistent global order to prevent deadlock.
- lockinguses · Locking is a synchronization technique that restricts concurrent access to shared resources or protected operations.
- circular dependencyproduced by · A circular dependency is a dependency relationship in which a chain of direct or indirect dependencies eventually returns to an earlier participant, forming a cycle.
- reentrant lockaddressed by · A reentrant lock is a mutual-exclusion lock that its owning thread can acquire repeatedly, requiring a matching release for each acquisition.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.














