2

我正在处理一个遗留项目,其中有人使用摆动计时器线程来执行一些服务器调度任务。这段代码不是一个swing应用程序,它是服务器端的java。我知道这不是一个好主意,并且知道可以接受的方法来做同样的事情。问题是,我看到在空载时每隔几分钟就会出现一些长时间的 VM 暂停。启用详细 gc,我确定它不是垃圾收集。当我在其中一个暂停期间执行线程转储时,我会在下面得到这个转储。知道此 AWTAutoShutdown 是否会导致此暂停,或者当它执行如下所示的 activateBlockerThread 时它在做什么?

"AWT-Shutdown" prio=10 tid=0x00007fed5802d000 nid=0x2ef1 in Object.wait() [0x00007fed53e5d000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x000000031e910b90> (a java.lang.Object)
at java.lang.Object.wait(Object.java:485)
at sun.awt.AWTAutoShutdown.run(Unknown Source)
- locked <0x000000031e910b90> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)

"TimerQueue" daemon prio=10 tid=0x00007fed58597000 nid=0x2a56 in Object.wait() [0x00007fed54737000]
java.lang.Thread.State: BLOCKED (on object monitor)
   at java.lang.Object.wait(Native Method)
   - waiting on <0x000000031e910b90> (a java.lang.Object)
   at java.lang.Object.wait(Object.java:485)
   at sun.awt.AWTAutoShutdown.activateBlockerThread(Unknown Source)
   at sun.awt.AWTAutoShutdown.notifyThreadBusy(Unknown Source)
   - locked <0x000000031e910b90> (a java.lang.Object)
   - locked <0x000000031e9a60c8> (a java.lang.Object)
   at java.awt.EventQueue.postEvent(Unknown Source)
   at java.awt.EventQueue.postEventPrivate(Unknown Source)
   - locked <0x000000031e90eb90> (a java.awt.EventQueue)
   at java.awt.EventQueue.postEvent(Unknown Source)
   at java.awt.EventQueue.invokeLater(Unknown Source)
   at javax.swing.SwingUtilities.invokeLater(Unknown Source)
   at javax.swing.Timer$1.run(Unknown Source)
   at javax.swing.Timer$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at javax.swing.Timer.post(Unknown Source)
   - locked <0x000000031e9af7e0> (a javax.swing.Timer)
   at javax.swing.TimerQueue.postExpiredTimers(Unknown Source)
   - locked <0x000000031e90ce60> (a javax.swing.TimerQueue)
   at javax.swing.TimerQueue.run(Unknown Source)
   - locked <0x000000031e90ce60> (a javax.swing.TimerQueue)
   at java.lang.Thread.run(Unknown Source)
4

1 回答 1

1

看来您可能遇到了通知问题。TimerQueue 线程应该在 AWT-Shutdown 线程启动后唤醒(AWTAutShutdown.run 方法向监视器发出 AWTAutShutdown.activateBlockerThread 方法正在等待的信号)。如果您的应用程序长时间冻结并且这些线程没有取得进展,那么 TimerQueue 线程似乎没有及时接收到信号。

但是,由于您的应用程序不是swing/awt 应用程序,我看不出这会如何影响应用程序中的其他任何内容。

于 2012-10-04T19:30:01.657 回答