-3

I have the following thread dump from a hung java swing application. It hung after a button is clicked and the GUI changed to blank. Other threads in socket communication and task management are still working (from the log file I can tell). I have removed some non-relevant output.

The #13 AW-EventQueue-0 should send out a command through the socket but it seems failed there. The #20 and #21 are AW-EventQueue-0-SharedResourceRunner which is not the same as the #13? It seems there is no deadlock but the GUI is not responsive and became blank.

do you see any useful information about the cause of the hanging?

Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.20-b23 mixed mode):

"DestroyJavaVM" #32 prio=5 os_prio=0 tid=0x00007f286c009800 nid=0xa41 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"TimerQueue" #22 daemon prio=5 os_prio=0 tid=0x00007f28002a8800 nid=0xa65 waiting on condition [0x00007f284c56f000]
   java.lang.Thread.State: WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x0000000088a8f5c0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
        at java.util.concurrent.DelayQueue.take(DelayQueue.java:211)
        at javax.swing.TimerQueue.run(TimerQueue.java:171)
        at java.lang.Thread.run(Thread.java:745)

"AWT-EventQueue-0-SharedResourceRunner" #21 daemon prio=6 os_prio=0 tid=0x00007f280021d000 nid=0xa64 in Object.wait() [0x00007f284d434000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x0000000088aec748> (a jogamp.opengl.SharedResourceRunner)
        at java.lang.Object.wait(Object.java:502)
        at jogamp.opengl.SharedResourceRunner.run(SharedResourceRunner.java:276)
        - locked <0x0000000088aec748> (a jogamp.opengl.SharedResourceRunner)
        at java.lang.Thread.run(Thread.java:745)

"AWT-EventQueue-0-SharedResourceRunner" #20 daemon prio=6 os_prio=0 tid=0x00007f28001f3000 nid=0xa63 in Object.wait() [0x00007f284f7f5000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x0000000088aed588> (a jogamp.opengl.SharedResourceRunner)
        at java.lang.Object.wait(Object.java:502)
        at jogamp.opengl.SharedResourceRunner.run(SharedResourceRunner.java:276)
        - locked <0x0000000088aed588> (a jogamp.opengl.SharedResourceRunner)
        at java.lang.Thread.run(Thread.java:745)

"AWT-EventQueue-0" #13 prio=6 os_prio=0 tid=0x00007f286c444800 nid=0xa59 in Object.wait() [0x00007f2858913000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00000000dc467018> (a java.lang.Object)
        at java.lang.Object.wait(Object.java:502)
        at com.mycp.common.task.BMBTaskBase.startTask(BMBTaskBase.java:551)
        - locked <0x00000000dc467018> (a java.lang.Object)
        at com.mycp.uiapp.workmgmt.WorkMgmtMgr.sendBegCmd(WorkMgmtMgr.java:334)
        at com.mycp.uiapp.workmgmt.WorkMgmtPanelBase.prepareAndSendBegWork(WorkMgmtPanelBase.java:559)
        at com.mycp.uiapp.workmmgmt.WorkMgmtPanel.prepareAndSendBegWork(WorkMgmtPanel.java:1479)
        at com.mycp.uiapp.workmgmt.WorkMgmtPanelBase.btnPrepareClicked(WorkMgmtPanelBase.java:363)
        at com.mycp.uiapp.workmgmt.WorkMgmtPanel.btnPrepareClicked(WorkMgmtPanel.java:1412)
        at com.mycp.uiapp.workmgmt.WorkMgmtPanel.actionPerformed(WorkMgmtPanel.java:1336)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)

"AWT-Shutdown" #14 prio=5 os_prio=0 tid=0x00007f286c443000 nid=0xa58 in Object.wait() [0x00007f2858a17000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x0000000088ae8c28> (a java.lang.Object)
        at java.lang.Object.wait(Object.java:502)
        at sun.awt.AWTAutoShutdown.run(AWTAutoShutdown.java:295)
        - locked <0x0000000088ae8c28> (a java.lang.Object)
        at java.lang.Thread.run(Thread.java:745)

"AWT-XAWT" #12 daemon prio=6 os_prio=0 tid=0x00007f286c384000 nid=0xa51 runnable [0x00007f285914f000]
   java.lang.Thread.State: RUNNABLE
        at sun.awt.X11.XToolkit.waitForEvents(Native Method)
        at sun.awt.X11.XToolkit.run(XToolkit.java:559)
        at sun.awt.X11.XToolkit.run(XToolkit.java:523)
        at java.lang.Thread.run(Thread.java:745)

"Java2D Disposer" #10 daemon prio=10 os_prio=0 tid=0x00007f286c35e000 nid=0xa50 in Object.wait() [0x00007f2859250000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x0000000087ab7ec0> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:142)
        - locked <0x0000000087ab7ec0> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:158)
        at sun.java2d.Disposer.run(Disposer.java:148)
        at java.lang.Thread.run(Thread.java:745)

"Thread-0" #9 prio=5 os_prio=0 tid=0x00007f286c234800 nid=0xa4f waiting on condition [0x00007f2859af5000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
        at java.lang.Thread.sleep(Native Method)
        at com.mycp.logging.BMBLogging$Task.run(BMBLogging.java:1072)
        at java.lang.Thread.run(Thread.java:745)

"Service Thread" #8 daemon prio=9 os_prio=0 tid=0x00007f286c0cf800 nid=0xa4d runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C1 CompilerThread2" #7 daemon prio=9 os_prio=0 tid=0x00007f286c0b2000 nid=0xa4c waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" #6 daemon prio=9 os_prio=0 tid=0x00007f286c0b0000 nid=0xa4b waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" #5 daemon prio=9 os_prio=0 tid=0x00007f286c0ad800 nid=0xa4a waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" #4 daemon prio=9 os_prio=0 tid=0x00007f286c0ab000 nid=0xa49 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" #3 daemon prio=8 os_prio=0 tid=0x00007f286c07c000 nid=0xa48 in Object.wait() [0x00007f285a2dd000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x0000000087a7e6c8> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:142)
        - locked <0x0000000087a7e6c8> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:158)
        at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)

"Reference Handler" #2 daemon prio=10 os_prio=0 tid=0x00007f286c07a000 nid=0xa47 in Object.wait() [0x00007f285a3de000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x0000000087a7e708> (a java.lang.ref.Reference$Lock)
        at java.lang.Object.wait(Object.java:502)
        at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:157)
        - locked <0x0000000087a7e708> (a java.lang.ref.Reference$Lock)

"VM Thread" os_prio=0 tid=0x00007f286c072800 nid=0xa46 runnable 

"GC task thread#0 (ParallelGC)" os_prio=0 tid=0x00007f286c01e800 nid=0xa42 runnable 

"GC task thread#1 (ParallelGC)" os_prio=0 tid=0x00007f286c020800 nid=0xa43 runnable 

"GC task thread#2 (ParallelGC)" os_prio=0 tid=0x00007f286c022000 nid=0xa44 runnable 

"GC task thread#3 (ParallelGC)" os_prio=0 tid=0x00007f286c024000 nid=0xa45 runnable 

"VM Periodic Task Thread" os_prio=0 tid=0x00007f286c0d2000 nid=0xa4e waiting on condition 

JNI global references: 485

Heap
 PSYoungGen      total 118272K, used 98176K [0x00000000d6e00000, 0x00000000de700000, 0x0000000100000000)
  eden space 113152K, 82% used [0x00000000d6e00000,0x00000000dc8e00c8,0x00000000ddc80000)
  from space 5120K, 100% used [0x00000000de180000,0x00000000de680000,0x00000000de680000)
  to   space 5120K, 0% used [0x00000000ddc80000,0x00000000ddc80000,0x00000000de180000)
 ParOldGen       total 159744K, used 76671K [0x0000000084a00000, 0x000000008e600000, 0x00000000d6e00000)
  object space 159744K, 47% used [0x0000000084a00000,0x00000000894dfc50,0x000000008e600000)
 Metaspace       used 30027K, capacity 30212K, committed 30464K, reserved 1077248K
  class space    used 3528K, capacity 3582K, committed 3584K, reserved 1048576K
peterboston
  • 877
  • 1
  • 12
  • 24
  • 1
    Just like your [previous question](http://stackoverflow.com/questions/35275201/my-swing-applicaiton-is-hanging-any-chance-to-find-out-why-now), post a [mcve] of your code. I want to see what it is you are doing that causes this. – user1803551 Feb 08 '16 at 20:05
  • I cannot. it is a more than a year long project and there are more than two hundreds thousand lines. And I cannot reproduce it. This is not school project. If I can reproduce it. I will not be here. – peterboston Feb 08 '16 at 20:14
  • 1
    "*It hung after a button is clicked*" You can't even show us what the button does? Also, if you can't reproduce it it will be really hard for us to help. Is te problem machine-dependent? Just sometimes? Is there networking involved in which case another machine might be part of the trigger? – user1803551 Feb 08 '16 at 20:17
  • 1
    If you've been programming for a year, surely you know what a stack trace is? I see two stack traces containing classes in subpackages of `com.mycp`. – VGR Feb 08 '16 at 20:18
  • @VGR I don't see any stack trace. That would make everything much easier. – user1803551 Feb 08 '16 at 20:19
  • There is no any exception. The application just not responsive. And above is the thread dump, even I removed some unrelevant stuff. That is what I have from Sun. I do failed to get the output from jstack because I got the thread dump first. As I said, my application running good 99.99% times. – peterboston Feb 08 '16 at 20:27
  • Every sequence of lines starting with `at` or `- locked` or `- waiting` is a stack trace. They show exactly where each thread which is in the [WAITING](http://docs.oracle.com/javase/8/docs/api/java/lang/Thread.State.html#WAITING) state is stuck. – VGR Feb 08 '16 at 20:40
  • 1
    Application not responsive and application is blank are 2 different things .. It could go blank because of UI issue as well, like some JS error have stopped the JS execution engine and hence page loading (if that is applicable), or there is no data etc. .. What exactly is happening with your application ?? – hagrawal7777 Feb 08 '16 at 20:49
  • 1
    This might help you out http://stackoverflow.com/questions/7599608/how-to-analyze-a-java-thread-dump – Millie Smith Feb 09 '16 at 03:20

2 Answers2

2

The thread dump shows stack traces from about 22 different threads. Many of them look like application threads (as opposed to JVM internal threads). Most of the application threads are waiting for something. Which of those threads should not be waiting?

I'd start by looking at thread 13: Looks like the Swing EDT, and it's waiting inside a call to a button's actionPerformed(...) handler. That can't be good.

Solomon Slow
  • 25,130
  • 5
  • 37
  • 57
0

I think I am late in the game. Anyways, from your logs we could see that a thread is in Parking Waiting state. "TimerQueue" #22 daemon prio=5 os_prio=0 tid=0x00007f28002a8800 nid=0xa65 waiting on condition [0x00007f284c56f000] java.lang.Thread.State: WAITING (parking)

We could see that this thread is expecting something from DelayQueue.

DelayQueue-An unbounded blocking queue of Delayed elements, in which an element can only be taken when its delay has expired.

So In the same TimerQueue, we have at java.util.concurrent.DelayQueue.take(DelayQueue.java:211)

This take() function waits if an element with expired delay is available on this queue. This could be the reason for application hanging issue as this thread is still waiting and doesn't shutdown. So, there are still threads alive. To resolve this you will need to kill these threads.

For this you could just use ExecutorServices.shutdown() method. OR Simply you could use System.exit().

I would recommend you to use System.exit().

user13579
  • 3
  • 2