Infinite loop in EventQueue.isDispatchThread()
2022-09-03 16:15:47
我有一个Java程序占用100%的CPU,但似乎什么都不做。
如果我采用线程转储,则有 4 个线程(在 5 个线程池中)等待获取锁。
"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)
他们正在等待的线程是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)
这是JDK 7.0.25,所以似乎有一个线程卡住了
EventQueue next = eq.nextQueue;
while (next != null) {
eq = next;
next = eq.nextQueue;
}
有两个 AWT 事件队列线程,尝试获取相同的 pushpoplock。
VM 作为服务运行,因此它不应尝试执行 AWT 操作,但它是由我正在使用的库完成的。
有什么想法吗?我可以防止这种情况发生吗?
谢谢!