Stopping Threads

Hi,

I wanted to stop some threads but the code below is an example of how it is not working. Are the threads interrupting themselves when I call interrupt() ? Does this mean if you want to stop a thread, it has to stop itself?

Thanks,

Michael

publicclass Test{

publicstaticvoid main(String[] args){

new Test().run();

}

publicvoid run(){

Thread a =new Test().new T();

Thread b =new Test().new T();

a.start();

b.start();

a.interrupt();

b.interrupt();

}

class Textends Thread{

publicvoid run(){

while(true){

System.out.println(this.getName());

}

}

}

}

[1615 byte] By [dalyma] at [2007-11-27 1:52:40]
# 1
OK, I have changed my threads to check a different object to see if they should continue another time round their loop.
dalyma at 2007-7-12 1:21:52 > top of Java-index,Core,Core APIs...
# 2
This should answer your questions: http://www.forward.com.au/javaProgramming/HowToStopAThread.html
ChuckBinga at 2007-7-12 1:21:52 > top of Java-index,Core,Core APIs...