Quick revision
The short answer
We take a thread dump with jcmd <pid> Thread.print, with jstack <pid>, or by sending kill -3 <pid>, which makes the JVM print the dump to its standard output. In the dump, BLOCKED means the thread is waiting to enter a synchronized block and shows 'waiting to lock <address>'; WAITING (parking) means it is parked by a java.util.concurrent lock, queue or future through LockSupport.park; and a 'locked <address>' line lists a monitor the thread currently holds. Because one dump is only a snapshot, we take several a few seconds apart to tell stuck threads from busy ones.
What to remember
In this answer, we took thread dumps with jcmd Thread.print, jstack and kill -3, and saw that kill -3 writes to the JVM's standard output. We read a thread entry from its header to its stack, matched 'waiting to lock' in BLOCKED threads with 'locked' in the owner, saw that WAITING (parking) comes from LockSupport.park under java.util.concurrent locks, queues and futures, used -l to find owners of ReentrantLocks through Locked ownable synchronizers, and took several dumps a few seconds apart to separate stuck threads from busy ones.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
We take a thread dump with jcmd <pid> Thread.print, with jstack <pid>, or by sending kill -3 <pid>, which makes the JVM print the dump to its standard output. In the dump, BLOCKED means the thread is waiting to enter a synchronized block and shows 'waiting to lock <address>'; WAITING (parking) means it is parked by a java.util.concurrent lock, queue or future through LockSupport.park; and a 'locked <address>' line lists a monitor the thread currently holds. Because one dump is only a snapshot, we take several a few seconds apart to tell stuck threads from busy ones.
Why this question is asked
A thread dump is the single most useful artefact when a Java service hangs or slows down. It costs nothing to take, needs no restart and no agent, and it shows exactly what every thread is doing at that instant and which locks it holds or wants. Interviewers ask about it because reading a dump well separates people who guess at performance problems from people who look. In this answer, we will see how to take a dump, walk through the parts of one thread entry, learn what BLOCKED, WAITING (parking) and the lock lines mean with a real example, and finish with why we always take more than one.
1Three Ways to Take a Thread Dump
First we need the process id, the pid. The jcmd tool with no arguments lists the running JVMs and their ids. Then any of the following commands asks the JVM to pause all threads briefly at a safe point, record every stack, and resume. The pause is usually a few milliseconds, so it is safe in production.
Notice the difference with kill -3: the dump does not come back to our terminal. It is written by the JVM to its own standard output, so in a container we find it with kubectl logs or in the log shipper. jcmd and jstack must run as the same user as the JVM, and inside a container they must run in the same container or a sidecar sharing its process namespace. Spring Boot applications can also expose a dump over HTTP through the actuator threaddump endpoint, which is convenient but must be secured.
2Reading One Thread Entry
Each thread in the dump starts with a header line and then shows its state and its stack, most recent call first. Here is a typical pair of threads in a service whose cache is protected by synchronized.
The header gives the thread name, which is often the most useful clue (http-nio-8080-exec is a Tomcat request thread), plus the CPU time it has used and the native thread id. The state line tells us what the thread is doing, and the stack tells us where. The lines that start with a dash are lock information, and the address in angle brackets identifies one particular lock object.
Notice that both threads mention the same address, 0x00000006c1a2b3d0. Thread exec-3 holds that monitor (locked) and is reading from a socket inside the synchronized method, so it is calling a remote pricing service while holding the cache lock. Thread exec-12 wants the same monitor (waiting to lock) and cannot proceed. If we find thirty threads waiting to lock that address, we have found our bottleneck: a network call inside a synchronized block.
3What BLOCKED, WAITING (parking) and the Lock Lines Mean
BLOCKED (on object monitor) means the thread is trying to enter a synchronized method or block, or re-enter one after Object.wait() returned, and another thread holds that monitor. A monitor is the lock built into every Java object that synchronized uses. The dump always pairs BLOCKED with 'waiting to lock <address>', so we can search for the same address with 'locked' to find the owner.
WAITING (parking) means the thread called LockSupport.park, the low-level primitive under the java.util.concurrent package. ReentrantLock, ReadWriteLock, Semaphore, CountDownLatch, BlockingQueue.take, Future.get and CompletableFuture.join all park their waiting threads. The stack shows jdk.internal.misc.Unsafe.park at the top and a line such as 'parking to wait for <0x...> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)', which names the object being waited on. TIMED_WAITING (parking) is the same with a timeout, as in poll(5, SECONDS).
A thread waiting for work in an idle pool is also WAITING (parking), on its queue's take(). So parking is not a problem by itself; what matters is what the thread is parked on. A plain WAITING (on object monitor) means Object.wait(), and the thread has released the monitor while it waits.
| State in the dump | Meaning | Lock line to look for |
|---|---|---|
| RUNNABLE | Running Java code or in native I/O | - locked <addr> for monitors it holds |
| BLOCKED (on object monitor) | Waiting to enter synchronized | - waiting to lock <addr> |
| WAITING (parking) | Parked by a j.u.c. lock, queue or future | - parking to wait for <addr> |
TIMED_WAITING (parking) | Same, with a timeout | - parking to wait for <addr> |
| WAITING (on object monitor) | Inside Object.wait(), monitor released | - waiting on <addr> |
TIMED_WAITING (sleeping) | Thread.sleep | none |
4Finding the Owner of a java.util.concurrent Lock
Monitors are easy because the owner shows 'locked <address>' in its stack. A ReentrantLock is different: it is a plain Java object, not a monitor, so the owner's stack does not mention it. This is what the -l option is for. With jstack -l or jcmd Thread.print -l, each thread ends with a section called Locked ownable synchronizers, listing the java.util.concurrent locks it holds.
So the parked threads and the owner meet at the same address, just as with monitors. If the JVM finds a cycle of threads each waiting for a lock the next one holds, it reports it at the end of the dump under 'Found one Java-level deadlock', which saves us the search.
5Why One Dump Is Never Enough
A thread dump is a photograph. If a thread appears in a slow method in one photograph, we cannot tell whether it has been stuck there for a minute or just happens to be passing through. So we take three to five dumps, about five to ten seconds apart, and compare them.
A thread that shows the same stack in every dump, with the same lock address, is stuck, and that is where we look. A thread that is RUNNABLE in different places each time is busy, which points at a CPU problem rather than a waiting problem. The header helps too: if the cpu= value of a thread grows a lot between dumps, it is burning CPU; if it barely moves while the thread stays in the same stack, it is waiting. Tools that group dumps by stack make patterns across 200 threads visible at a glance.
6Follow-up questions
What is the difference between BLOCKED and WAITING on a monitor?
BLOCKED means the thread wants to enter a synchronized region and someone else holds the monitor, so it cannot proceed until the owner leaves. WAITING (on object monitor) means the thread called wait() on an object; it has given up the monitor voluntarily and is waiting to be notified. After notify, it goes through BLOCKED briefly while it reacquires the monitor.
Why might a thread dump not show a deadlock that clearly exists?
The JVM's automatic detection covers monitors and java.util.concurrent ownable synchronizers, but not every kind of waiting. Two threads each waiting on a future the other should complete, or a thread pool whose tasks wait for other tasks queued in the same full pool, are deadlocks in effect but involve no lock cycle. We find those by reading what the parked threads wait for.
7Conclusion
In this answer, we took thread dumps with jcmd Thread.print, jstack and kill -3, and saw that kill -3 writes to the JVM's standard output. We read a thread entry from its header to its stack, matched 'waiting to lock' in BLOCKED threads with 'locked' in the owner, saw that WAITING (parking) comes from LockSupport.park under java.util.concurrent locks, queues and futures, used -l to find owners of ReentrantLocks through Locked ownable synchronizers, and took several dumps a few seconds apart to separate stuck threads from busy ones.
Open with
To take a thread dump I find the pid with jcmd and run jcmd pid Thread.print, or jstack pid, adding -l when I want java.util.concurrent lock owners. kill -3 also works, but the dump goes to the JVM's standard output, so in a container I read it from the logs.
Then, if they want more
In each entry I look at the thread name, the state and the stack. BLOCKED on object monitor means the thread is trying to enter a synchronized block that another thread holds, and the dump shows waiting to lock with an address.
I search that address for a locked line to find the owner and see what it is doing, often I/O inside the synchronized block. WAITING parking means the thread went through LockSupport.park, so it is waiting on a ReentrantLock, a blocking queue, a latch or a future, and the parking to wait for line names the object.
Idle pool threads park on their queue, so parking alone is not a problem; what it waits on matters. With -l, the Locked ownable synchronizers section shows who holds a ReentrantLock.
And because a dump is a snapshot, I take three to five dumps five or ten seconds apart: threads with the same stack and lock in every dump are stuck, while threads in different places each time are just busy, which points at CPU rather than contention.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- java.util.concurrent, package documentation, JLS chapter 17, Threads and Locks
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "How do you take a thread dump of a running JVM, and what do BLOCKED, WAITING (parking)...": https://scrivio-interview-library.netlify.app/java/concurrency-problems/320d76d240/