[concurrency-interest] ThreadPoolExecutors and System.exit

Paulo Levi i30817 at gmail.com
Fri Jan 1 10:27:46 EST 2010


I forgot to "reply to all" and had some responses that were only being sent
to Mr. Andreou. I will transcribe them.

For the record i think this might be a combination of the state Mr. Berlin
says he as seen and the problem in the link in the last reply bellow. I
can't get a thread dump when this state happens but i can do it using a
Shutdown Hook (presumably before the jre shutdowns)

This are the missing responses - i will now try to comment the invokeLater
part of my tasks to see if they terminate now:


---------- Forwarded message ----------
From: Paulo Levi <i30817 at gmail.com>
Date: Thu, Dec 31, 2009 at 2:57 AM
Subject: Re: [concurrency-interest] ThreadPoolExecutors and System.exit
To: Dimitris Andreou <jim.andreou at gmail.com>


Well, after adding the shutdown hook for the ThreadPoolExecutors subclass
and calling shutdownnow on them inside it, it always terminated (when it
almost always didn't in this dual core). Its possible i'm doing something
wrong in the tasks (there is a URL connection opened there and a file
written/read) that the interrupt call of the shutdownnow "fixes". That is
what i suspect.


On Thu, Dec 31, 2009 at 2:45 AM, Dimitris Andreou <jim.andreou at gmail.com>wrote:

> Hi Paulo,
>
> The application can't hang just because a daemon thread hangs. It's
> the other way around - daemon threads live because there is a
> non-daemon thread still active. Are you sure you terminate all
> non-daemon threads when the application is "closed"?
>
> Dimitris
>
> 2009/12/31 Paulo Levi <i30817 at gmail.com>:
> > I have a TPE subclass and i'm seeing (disturbingly only on some dual core
> > processors) a hang when the application is closed and there are lots of
> > tasks to be processed. Specifically no-more tasks appear to be processed,
> > but the (daemon) threads are still alive at the time shutdown hooks are
> > called.
> > (daemon, alive, not interrupted).
> >
> > Threadfactory used by the subclass creates daemon threads, and the class
> is
> > configurated with a keepAliveTime > 0 in this case (to reuse the threads)
> > and a LIFO queue instead of the normal one.
> >
> > I appear to be able to avoid it with a shutdown hook, but i would like to
> > know if all ThreadPoolExecutors are vulnerable to this.
> >
> > (disturbingly too, after this, the debugger says the java process is
> closed,
> > however windows task manager disagrees).
> >
> > _______________________________________________
> > Concurrency-interest mailing list
> > Concurrency-interest at cs.oswego.edu
> > http://cs.oswego.edu/mailman/listinfo/concurrency-interest
> >
> >
>


---------- Forwarded message ----------
From: Paulo Levi <i30817 at gmail.com>
Date: Thu, Dec 31, 2009 at 3:11 AM
Subject: Re: [concurrency-interest] ThreadPoolExecutors and System.exit
To: Dimitris Andreou <jim.andreou at gmail.com>


Besides there is the very suspicious fact that i couldn't get a thread dump
when i closed the main window,(CTRL+Break right?) and the profiler/debugger
told me the application was finished but the console didn't terminate (same
thing in the command-line console). That is what blew my mind.

The alive non-demon threads alive at the time the shudown hooks run are :
AWT-Shutdown
AWT-EventQueue-0
DestroyJavaVM

(there are some !isAlive()).



---------- Forwarded message ----------
From: Paulo Levi <i30817 at gmail.com>
Date: Thu, Dec 31, 2009 at 3:17 AM
Subject: Re: [concurrency-interest] ThreadPoolExecutors and System.exit
To: Dimitris Andreou <jim.andreou at gmail.com>


Now seeing that AWT-Shutdown, its possible that one of my tasks posts a
event to the EDT (as described here : http://www.pushing-pixels.org/?p=369).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20100101/707dd06a/attachment.html>


More information about the Concurrency-interest mailing list