[concurrency-interest] ThreadPoolExecutors and System.exit

Paulo Levi i30817 at gmail.com
Fri Jan 1 13:21:36 EST 2010


It doesn't appear to be it :(

I used Xbootclasspath/p: to use a new EventQueue class that made a
system.out.println with a counter on the
private void postEvent(AWTEvent theEvent, int priority) that is used by all
event posting and it doesnt increment after closing.

It appears to be something else that is keeping the AWT thread alive.
Using a shutdown hook to dump the stack of the anomalous (?) alive
AWT-EventQueue-0
gives this
....
EVENT 496
EVENT 497
java.lang.Object.wait(Native Method)
EVENT 498
java.lang.Thread.join(Thread.java:1269)
java.lang.Thread.join(Thread.java:1343)
java.lang.ApplicationShutdownHooks.runHooks(ApplicationShutdownHooks.java:106)
java.lang.ApplicationShutdownHooks$1.run(ApplicationShutdownHooks.java:46)
java.lang.Shutdown.runHooks(Shutdown.java:123)
java.lang.Shutdown.sequence(Shutdown.java:167)
java.lang.Shutdown.exit(Shutdown.java:212)
java.lang.Runtime.exit(Runtime.java:107)
java.lang.System.exit(System.java:954)
javax.swing.JFrame.processWindowEvent(JFrame.java:312)
java.awt.Window.processEvent(Window.java:1961)
java.awt.Component.dispatchEventImpl(Component.java:4790)
java.awt.Container.dispatchEventImpl(Container.java:2261)
java.awt.Window.dispatchEventImpl(Window.java:2671)
java.awt.Component.dispatchEvent(Component.java:4616)
java.awt.EventQueue.dispatchEvent(EventQueue.java:654)
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:255)
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:170)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:160)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:155)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
java.awt.EventDispatchThread.run(EventDispatchThread.java:136)


So it appears to be normal that AWT runs the shutdownhooks and waits for
them to die before exiting. Commenting the main shutdown hook of my
application doesn't have a effect.

Then i also replaced the Shutdown auxilialy class to see if the application
progressed beyond the java.lang.Shutdown.sequence call (disabled the event
printing for legibility). I put a dump of all non-daemon alive threads
before the native halt0 method. This is the result in a hanging case.

current thread = AWT-EventQueue-0
Stack of AWT-Shutdown:
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:502)
sun.awt.AWTAutoShutdown.run(AWTAutoShutdown.java:287)
java.lang.Thread.run(Thread.java:717)

Stack of AWT-EventQueue-0:
java.lang.Thread.getStackTrace(Thread.java:1578)
java.lang.Shutdown.halt(Shutdown.java:148)
java.lang.Shutdown.exit(Shutdown.java:238)
java.lang.Runtime.exit(Runtime.java:107)
java.lang.System.exit(System.java:954)
javax.swing.JFrame.processWindowEvent(JFrame.java:312)
java.awt.Window.processEvent(Window.java:1961)
java.awt.Component.dispatchEventImpl(Component.java:4790)
java.awt.Container.dispatchEventImpl(Container.java:2261)
java.awt.Window.dispatchEventImpl(Window.java:2671)
java.awt.Component.dispatchEvent(Component.java:4616)
java.awt.EventQueue.dispatchEvent(EventQueue.java:653)
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:255)
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:170)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:160)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:155)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
java.awt.EventDispatchThread.run(EventDispatchThread.java:136)

Stack of DestroyJavaVM:

(empty)




As i said before it can work around this and i believe now i know what is
the part of the task that is causing this (a opening a url connection on a
daemon thead in the TPE at this time), but i would like to find the cause so
the culprit can be corrected upstream. However i think i reached the limit
of my debugging capabilities.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20100101/ba5ccd72/attachment.html>


More information about the Concurrency-interest mailing list