avalon-phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <pe...@apache.org>
Subject Re: Correct way to interrupt threads in dispose...
Date Wed, 22 May 2002 23:59:27 GMT
On Thu, 23 May 2002 08:48, Andrei Ivanov wrote:
> when it is time do dispose I have the following lines inside dispose():
>
>     for (Iterator i = threads.iterator(); i.hasNext(); ) {
>       ThreadControl tc = (ThreadControl)i.next();
>       tc.interupt();
>     }
>     notifyAll();

Java does not allow you to do a notifyAll() unless you own the synchronization 
lock on specified component. So you should do

synchronized( this ) { notifyAll(); }

BTW I would recomend that you do a join() on ThreadControl to verify that 
threads have shutdown before block does.

-- 
Cheers,

Peter Donald


--
To unsubscribe, e-mail:   <mailto:avalon-phoenix-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-phoenix-dev-help@jakarta.apache.org>


Mime
View raw message