I have a Java program taking 100% cpu, but seemingly doing nothing.
If I take a thread dump, there are 4 threads (out of a pool of 5) waiting to take a lock.
"Incoming WorkPool 5" - Thread t@363
java.lang.Thread.State: WAITING
at sun.misc.Unsafe.park(Native Method)
- waiting to lock <7212149b> (a java.util.concurrent.locks.ReentrantLock$NonfairSync) owned by "Incoming WorkPool 3" t@354
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:867)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1197)
at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:214)
at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:290)
at java.awt.EventQueue.isDispatchThreadImpl(EventQueue.java:1019)
at java.awt.EventQueue.isDispatchThread(EventQueue.java:1014)
The thread they are waiting for is RUNNABLE
"Incoming WorkPool 3" - Thread t@354
java.lang.Thread.State: RUNNABLE
at java.awt.EventQueue.isDispatchThreadImpl(EventQueue.java:1024)
at java.awt.EventQueue.isDispatchThread(EventQueue.java:1014)
This is JDK 7.0.25, so it seems one thread is stuck on
EventQueue next = eq.nextQueue;
while (next != null) {
eq = next;
next = eq.nextQueue;
}
There are two AWT EventQueue threads, trying to acquire the same pushpoplock.
The VM runs as a service, so it shouldn't try to do AWT stuff, but it's done by a library I'm using.
Any ideas? Can I prevent this from happening?
Thanks!
Is there any possibility that push(EventQueue newEventQueue)
is called by your application program and that pushes the same eventQueue? If yes, then, this
and its nextQueue
will be same objects and they will be running in an endless loop consuming CPU to 100%.
From the stack trace its evident that at least one thread is running. So its not a question of DEADLOCK.
From the 100% CPU consumption hint and its state as RUNNABLE, its evident its doing an infinite loop.
The code can go into infinite loop if and only if the nextQueue
has a value that's already in the chain (or this
). It could very well be an application problem. Thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With