Re: refusal to quit
On Fri, 29 Aug 2014 09:56:45 -0700, Roedy Green
<see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :
Sometimes programs simply refuse to quit after main has terminated.
I sprinkled a call to this code in every main.
/**
* call just before System.exit( 0 ) to find out if there was more
than one thread.
*/
public static void trackLastThread()
{
final int activeCount = Thread.activeCount();
if ( activeCount == 1 )
{
return;
}
else
{
out.println( activeCount + " threads " );
}
final Thread[] ta = new Thread[ activeCount ];
Thread.enumerate( ta );
for ( Thread t : ta )
{
out.println( "T H R E A D" );
out.println( t.toString() );
final StackTraceElement[] s = t.getStackTrace();
for ( StackTraceElement e : s )
{
out.println( e.toString() );
}
out.println();
}
} // /method
In one case it said that a Timer was still running. I thought
Timer.cancel would be sufficient to kill it, but apparently not.
I gather it just stops the periodic calls to run, but leaves the
thread alive.
--
Roedy Green Canadian Mind Products http://mindprod.com
Errors using inadequate data are much less than those using no data at all.
~ Charles Babbage (born: 1791-12-26 died: 1871-10-18 at age: 79)