java-死锁上发生奇怪的线程转储

在启动Java应用程序期间,我们一直遇到一个奇怪的死锁.当我在应用程序上运行jstack进行调查时,我看到AWT-EventQueue在Object.wait()中,但是该线程仍被标记为RUNNABLE.我已经包括了线程转储的相关部分,并且希望有人可以对此问题有所了解.

"AWT-EventQueue-0" prio=6 tid=0x5f0a2400 nid=0x19e4 in Object.wait() [0x6007e000]
       java.lang.Thread.State: RUNNABLE
        at com.ge.med.platinum.work.isu.ExamTransaction.getEAOTableLite(ExamTransaction.java:1514)
          ...
          - locked <0x1fc87448> (a java.awt.Component$AWTTreeLock)
          ...

"Thread-63-Pool-9" prio=6 tid=0x5f1a2800 nid=0x1f54 waiting for monitor entry [0x61a9f000]
   java.lang.Thread.State: BLOCKED (on object monitor)
    at java.awt.Component.setFont(Component.java:1777)
    - waiting to lock <0x1fc87448> (a java.awt.Component$AWTTreeLock)
      ...

"Thread-289-Pool-3" prio=6 tid=0x60afe800 nid=0x12b8 waiting for monitor entry [0x623fe000]
   java.lang.Thread.State: BLOCKED (on object monitor)
    at java.awt.Component.setFont(Component.java:1777)
    - waiting to lock <0x1fc87448> (a java.awt.Component$AWTTreeLock)
      ...

此外,我注意到this thread,其中提到可能涉及访问静态变量.在我们的应用程序中也是如此.有问题的getEAOTableLite中的行引用了静态方法.

解决方法:

我不确定如何错过它,但是如果我更好地阅读了堆栈跟踪信息,我会发现问题是EAOAlertManager类的静态初始化最终将调用Component.setFont()方法,该方法已被AWT-EventQueue阻止(在EventQueue外部调用setFont()是非法的).然后,EventQueue返回到ExamTransaction.getEAOTableLite中,这意味着它将再次引用EAOAlertManager类,从而使其等待该类完成加载.但是EAOAlertManager类正在等待EventQueue.我的朋友们,那是一个僵局.

"Thread-289-Pool-3" prio=6 tid=0x60afe800 nid=0x12b8 waiting for monitor entry [0x623fe000]
   java.lang.Thread.State: BLOCKED (on object monitor)
    at java.awt.Component.setFont(Component.java:1777)
    - waiting to lock <0x1fc87448> (a java.awt.Component$AWTTreeLock)
    at java.awt.Container.setFont(Container.java:1554)
    at javax.swing.JComponent.setFont(JComponent.java:2723)
    at javax.swing.LookAndFeel.installColorsAndFont(LookAndFeel.java:191)
    at javax.swing.plaf.basic.BasicPanelUI.installDefaults(BasicPanelUI.java:49)
    at javax.swing.plaf.basic.BasicPanelUI.installUI(BasicPanelUI.java:39)
    at com.ge.med.ptk.laf.CuiPanelUI.installUI(CuiPanelUI.java:53)
    at javax.swing.JComponent.setUI(JComponent.java:662)
    at javax.swing.JPanel.setUI(JPanel.java:136)
    at javax.swing.JPanel.updateUI(JPanel.java:109)
    at javax.swing.JPanel.<init>(JPanel.java:69)
    at javax.swing.JPanel.<init>(JPanel.java:92)
    at javax.swing.JPanel.<init>(JPanel.java:100)
    at javax.swing.JRootPane.createGlassPane(JRootPane.java:528)
    at javax.swing.JRootPane.<init>(JRootPane.java:348)
    at javax.swing.JDialog.createRootPane(JDialog.java:611)
    at javax.swing.JDialog.dialogInit(JDialog.java:593)
    at com.ge.med.plaf.wrapper.WJDialog.dialogInit(WJDialog.java:42)
    at javax.swing.JDialog.<init>(JDialog.java:545)
    at javax.swing.JDialog.<init>(JDialog.java:515)
    at com.ge.med.plaf.wrapper.WJDialog.<init>(WJDialog.java:424)
    at com.ge.med.platinum.gui.util.PlatinumDialog.<init>(PlatinumDialog.java:138)
    at com.ge.med.platinum.gui.util.EAOAlertManager$EAOAlertDialog.<init>(EAOAlertManager.java:450)
    at com.ge.med.platinum.gui.util.EAOAlertManager.<clinit>(EAOAlertManager.java:77)
    at com.ge.med.platinum.work.isu.ExamTransaction.getEAOTableLite(ExamTransaction.java:1514)
上一篇:Java线程:解释正在运行的JVM的线程状态


下一篇:linux下查java进程的那个线程占用CPU过高原因