java
10 minJava Thread Dumps: Find Deadlocks, Starvation, and Lock Contention
Use repeated thread dumps and thread-state patterns to distinguish deadlocks from slow dependencies, starvation, and excessive synchronization.
Loading page...
java
10 minUse repeated thread dumps and thread-state patterns to distinguish deadlocks from slow dependencies, starvation, and excessive synchronization.
databases
10 minUnderstand transaction conflicts, lock waits, isolation anomalies, and safe retry boundaries across relational databases.
Q&A
Q&AFind a cycle in lock ownership and waiting, then remove inconsistent nested lock ordering.
Capture repeated thread dumps with jcmd or jstack while the incident is active. A deadlock cycle shows threads waiting for locks held by each other; distinguish it from starvation or a slow dependency by checking whether owners can progress. Fix consistent lock order, shorten critical sections, or redesign ownership so both locks are not required together.
Q&A
Q&ARetry the whole idempotent transaction within a bounded policy, not just an arbitrary statement.
A deadlock detector aborts one transaction so another can progress. Capture lock and query evidence, then retry the whole business transaction only if its effects are safe to repeat. Use bounded attempts with jitter, consistent resource ordering, and idempotency for any external side effects.
Q&A
Q&AWorkers can all block waiting for child tasks queued to the same exhausted executor.
If every worker submits a task to the same bounded executor and synchronously waits for that task, no worker remains to run queued children. This is thread-pool starvation, not necessarily a monitor deadlock. Avoid blocking composition on the same pool, separate workloads, or use asynchronous completion and bounded concurrency.
Q&A
Q&APooled threads outlive requests, so forgotten thread-local values can leak data and memory across tasks.
Thread pools reuse worker threads. A ThreadLocal value can remain attached after a request ends, retaining large objects or exposing one request’s context to a later task if it is not overwritten. Clear it in a finally block or use a scoped context mechanism with well-defined propagation and cleanup.
java
18 minA production field guide to GC choice, thread-pool saturation, Spring lifecycle traps, AOP boundaries, and blocking work in reactive services.