You are viewing a plain text version of this content. The canonical link for it is here.
Posted to phoenix-dev@avalon.apache.org by Andrei Ivanov <my...@surfeu.fi> on 2002/05/23 00:48:02 UTC
Correct way to interrupt threads in dispose...
Hi,
In my Phoenix block I am using threads in the following way:
member:
LinkedList threads = new LinkedList();
in initialize():
ThreadPool workerPool = threadManager.getThreadPool("default");
...
for ( int i = 0 ; i < nthreads ; i++ ) {
ThreadControl tc = workerPool.execute(this);
threads.add(tc);
}
...
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();
Today, after updating cornerstone and phoenix I've got exception upon
Phoenix shutdown:
org.apache.avalon.phoenix.components.lifecycle.LifecycleException: Component
named "xxxxx" failed to pass through the Disposing stage. (Reason:
java.lang.IllegalMonitorStateException: current thread not owner).
at
org.apache.avalon.phoenix.components.lifecycle.LifecycleHelper.fail(Lifecycl
eHelper.java:280)
at
org.apache.avalon.phoenix.components.lifecycle.LifecycleHelper.shutdown(Life
cycleHelper.java:221)
What is wrong with my dispose() in respect of latest changes in cornerstone
and phoenix?
Andrei
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Correct way to interrupt threads in dispose...
Posted by Peter Donald <pe...@apache.org>.
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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>