depricated. You should use use Thread interrupt to stop the thread.
When you remove the Thread object from the hashtable issue a Thread.interrup()
call so the thread object unwinds correctly and exits the run method then set the obejct reference to null so on the next GC pass the dead thread object will be garbage collected.
Example:
class xxxxxx implements Runnable {
// class code here
void run() {
try {
while(true) {
// some code here
}
}
catch(InterruptedException e) {
e.printStackTrace();
return;
}
}
}
}
Cheers
Chris
yangyuex wrote:
Hi I have several threads in one hashtable. When I remove one of them, whether this thread still consume CPU etc resources? That's to say, if I will not need one thread, whether I must stop or destory it explictly or just remove it from hashtable for garbage collection? I am not sure how JVM schedules multiple threads.Thanks very much! yangyuexiang ---------------------------------------------------------------------- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]