the accepted way for thread X to terminate thread Y is to provide a method in Y, MyStopMethod, that knows how to terminate itself using flags and proper "waking". do something like this:
void run()
{
while ( continueProcessing )
{
// do something
}
} // run
void MyStopMethod()
{
continueProcessing = false;
// notify thread if necessary to "wake it up"
} // MyStopMethod
it is not recommended to use the "stop" method in the Thread class, and in fact, it has been deprecated in java 2.
> Try showing some duke dollars and you will get a
> better response.
Are you assuming that greedy individuals are smarter and more well informed than generous, giving and altruistic people? I guess I wouldn't make that same assumption. Unless you are including Scrooge McDuck whose genius simply cannot be denied!:)
> > Try showing some duke dollars and you will get a
> > better response.
>
> Are you assuming that greedy individuals are smarter
> and more well informed than generous, giving and
> altruistic people? I guess I wouldn't make that same
> assumption. Unless you are including Scrooge McDuck
> whose genius simply cannot be denied!:)
Does one have to be greedy to be addicted to useless duke dollars ;)
> Oh yes, interrupt does not leave the thread in an
> undetermined state, all the problems related to
> calling stop() don't happen.
He said 'terminate' not 'interrupt.' These are 2 differen things.
Interrupting a thread most certainly can leave it in an indeterminate state, if you didn't write the thread.
Calling interrupt is not really going to do anything (if you wrote the thread yourself), unless your thread is actively polling to see if it should be interrupted.
Correct measures have already been posted.