On 5/11/2011 8:37 AM, Alan Bateman wrote:
On 04/11/2011 15:52, Gary Adams wrote:
:

I'll attempt a simple fix for the KillThread case by replacing :

Thread.sleep(100);

with a simple loop

do {
Thread.sleep(100);
} while (waiting);

where the TimerTask runnable will clear the flag
with "waiting = false " once it has been launched.

I don't think this will guarantee that the timer thread will have
terminated before the main thread schedules the second event. I think
this test would be robust if you capture a reference to the timer thread
in the first task and have the main thread wait or poll until it has a
reference to the thread. Once it has a reference to the thread then it
can wait for it to terminate before attempting to schedule the second task.

Agreed. As soon as waiting is set we can switch back to the main thread and proceed to the next phase of the test - but the timer thread is still alive at that point. If the issue is checking for thread termination then we must track that directly.

David
-----

-Alan.

Reply via email to