Posted By:
eric_chang
Posted On:
Friday, October 29, 2004 03:17 AM
Dear Sir, I understand I need to use interrupt to kill the Thread but I can't apply in my program. The program is like this : public void run() { // There are a thousand lines of codes in the following without looping System.out.println("This is statement l"); System.out.println("This is statement 2"); System.out.println("This is statement 3"); ... ... } If interrupt() need to be used, the while loop must be used to check the value as below; public void run() { while (!interrupted()) { System.out.println("This is statement l"); Syst
More>>
Dear Sir,
I understand I need to use interrupt to kill the Thread but I can't apply in my program.
The program is like this :
public void run() {
// There are a thousand lines of codes in the following without looping
System.out.println("This is statement l");
System.out.println("This is statement 2");
System.out.println("This is statement 3");
...
...
}
If interrupt() need to be used, the while loop must be used to check the value as below;
public void run() {
while (!interrupted()) {
System.out.println("This is statement l");
System.out.println("This is statement 2");
System.out.println("This is statement 3");
...
...
}
}
Finally, the program logic is changed and the result is different. I would like to stop the thread at any time.
Furthermore there are a thousands of the different report(one thread per one report) exists in our system. How can I overcome the problem if stop method cannot be used.
For the reports, there are no lock mechansim and it is only a read process, if I insist to use the 'stop', is it any other side effect other than the lock or memory
resource
Please help !!!
Thanks & Regards,
Eric
<<Less