On this page
Short answer
When Tomcat requests hang while CPU stays idle, the request threads are waiting, not working. The usual cause is every thread in the pool (200 by default) blocked on a database pool or an outbound call with no timeout. Take three thread dumps ten seconds apart and group the exec threads by the frame they wait in.
When Tomcat requests hang while CPU stays idle, the request threads are waiting, not working. The usual cause is every thread in the pool (200 by default) blocked on a database pool or an outbound call with no timeout. Take three thread dumps ten seconds apart and group the exec threads by the frame they wait in.
This guide goes past the connector defaults covered in our how to run Tomcat in production post and into diagnosis. If a node is hung now, our Tomcat consulting engineers start from the same three dumps, and the steps below use Tomcat 10.1 behaviour.
Why does Tomcat hang when CPU is idle?
Because each non-asynchronous request holds one thread for its whole duration, so a few slow dependencies can occupy every thread while using almost no CPU. New requests then wait in the connection queues, and the application looks frozen. From outside it appears as timeouts, or as a 503 from the proxy in front, while the server shows low CPU usage.
Tomcat applies its limits in order. The table shows what each one looks like during a hang.
| Limit | Default (10.1 docs) | What it looks like when full |
|---|---|---|
maxThreads | 200 | Every exec thread busy; new requests wait |
maxConnections | 8192 (NIO, NIO2) | Tomcat accepts one more connection but does not process it |
acceptCount | 100 | Operating system queue; beyond it, connections are refused or time out |
How do I take a thread dump of a hung Tomcat?
Take three dumps about ten seconds apart, so you can tell a stuck thread from a slow one.
- List the JVMs with
jcmdand note the Tomcat process ID. - Run
jcmd <pid> Thread.print -l > dump1.txt. The-loption addsjava.util.concurrentlock information. - Wait ten seconds and repeat for dump2 and dump3.
- Save the Tomcat log and the dumps together before you restart anything.
for i in 1 2 3; do jcmd <pid> Thread.print -l > dump$i.txt; sleep 10; done
Prefer jcmd to jstack: the JDK 21 manual calls jstack experimental and unsupported, and rates Thread.print impact as medium, depending on the number of threads.
What should I look for in the dumps?
Count the threads named http-nio-8080-exec-N (the number follows your connector port) and group them by the frame they wait in. A frame that holds most of the pool and is identical in all three dumps is your stall.
| Where the exec threads wait | Likely cause | Check next |
|---|---|---|
Pool borrowObject or getConnection | Database pool exhausted or connections leaked | Pool size and wait limit |
| Socket read inside an HTTP client | Outbound call with no read timeout | Client connect and read timeouts |
BLOCKED, waiting to lock the same monitor | Lock contention in application code | The thread that holds the lock, in the same dump |
| Few exec threads, mostly idle | The wait is upstream of Tomcat | Proxy, load balancer and DNS |
If the same threads sit in the same frames across all three dumps they are stuck. If the frames change, the system is slow rather than hung, and the fix is capacity or a slow query.
How do I rule out garbage collection and the heap?
Read the dumps for state. Threads that are waiting on a pool, a socket or a lock point to a dependency. Threads that are RUNNABLE in application code, or a process that pauses as a whole, point to the JVM: check the garbage collection log for long pauses and compare heap use with the configured maximum.
A long garbage collection pause stops every request thread at once and shows in the GC log, not in the dumps, so keep the log next to the three dumps.
Which pool or timeout is usually behind the hang?
The database pool is the most common culprit, because its defaults favour waiting. The Apache Commons DBCP configuration page lists maxTotal as 8 and maxWaitMillis as indefinite, so 192 of 200 request threads can queue for 8 connections with no error. Set maxWaitMillis to a few seconds so an exhausted pool becomes a logged exception.
DBCP also ships with removeAbandonedOnBorrow and logAbandoned both false, so a leaked connection stays invisible until you turn them on.
Add StuckThreadDetectionValve to find the next stall without a manual dump. Its threshold defaults to 600 seconds, so lower it to a value just above your slowest legitimate request. The valve logs the stuck thread's stack at WARN and exposes stuckThreadIds and stuckThreadNames through JMX. interruptThreadThreshold is -1 by default; the docs say interrupting usually helps with threads blocked on I/O or locks but is probably useless for infinite loops.
How do I stop it coming back?
- Put a connect and a read timeout on every outbound call. Tomcat cannot enforce them for your code.
- Cap the wait on every pool. A pool error in the log beats a silent queue.
- Leave
maxThreadsalone until the dumps show threads busy on CPU work. See the defaults in how to run Tomcat in production. - Keep the dump command in your runbook, with a person who knows how to read it.
AceMQ's senior engineers read dumps like these with your team, with 24/7 cover and response targets from 15 minutes, by plan. For a review of your executor and pool settings against real dumps, see our connector and thread pool review.
Sources
- tomcat.apache.org/tomcat-10.1-doc/config/http.html, read 3 December 2026.
- tomcat.apache.org/tomcat-10.1-doc/config/valve.html, read 3 December 2026.
- commons.apache.org/proper/commons-dbcp/configuration.html, read 3 December 2026.
- docs.oracle.com/en/java/javase/21/docs/specs/man/jcmd.html, read 3 December 2026.
- docs.oracle.com/en/java/javase/21/docs/specs/man/jstack.html, read 3 December 2026.
Frequently Asked Questions
Will a larger maxThreads fix a Tomcat hang?
Rarely. If the threads are waiting on a database pool or an outbound call, a bigger pool only queues more requests behind the same stall. Find what the threads wait on first, then size the pool.
Is it safe to take a thread dump of a production Tomcat?
Generally yes, with `jcmd <pid> Thread.print`. The JDK 21 documentation rates its impact as medium and dependent on the number of threads. It marks `jstack` as experimental and unsupported, so prefer `jcmd`.
What does Tomcat's StuckThreadDetectionValve do by default?
It writes the stack of any request running longer than 600 seconds to the log at WARN level. It does not interrupt the thread unless you set `interruptThreadThreshold`, which defaults to -1.
Talk to an engineer
Need a hand with Tomcat?
Senior engineers who run it in production. Get a quote or a free consultation, no sales pitch.

