Skip to content
Ameen Abozaid
Planned lessonMID-004-L09

Demo: diagnosing a deadlock from a thread dump

  • Lesson 9 of 9
  • Mid-level
On This Lesson 3 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

read a thread dump and fix the cause.

Draft outline details

Step by step

  1. Run a Shop transfer(from, to) that locks both accounts in argument order; fire opposite transfers concurrently.
  2. The app hangs; take a dump with jcmd <pid> Thread.print.
  3. Find the "Found one Java-level deadlock" section; read which thread holds which lock and waits for which.
  4. Planned mistake: restart the app and call it solved. Fix: record the dump, identify the lock order, then fix it.
  5. Apply ordered locking (lower id first) and rerun the stress test; no hang.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Type to search levels, phases, modules and lessons.