I noticed that my java application (runs on tomcat6) spawns a lot of threads which do not terminate.
So I created a thread dump and noticed that there are tons of threads waiting, like this:
"pool-1-thread-22" prio=5 tid=101b4b000 nid=0x127122000 waiting on condition [127121000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <6c340cee0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:156)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:399)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:947)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:680)
Locked ownable synchronizers:
- None
Now the question is: WHAT are these threads waiting for?
I have suspect class which seems to spawn these threads but I don’t know what exactly is making these threads stuck.
Is there anything I can do to find the cause for this except for tearing the class apart line by line and keep monitoring thread behavior?
On tomcat, they’re usually request worker threads waiting for someone to connect.
Nothing to worry about. They’re ready to handle those 100 users connecting at once to your server.