| Author |
Stopping multi-thread
|
Derek Bright
Greenhorn
Joined: Aug 28, 2008
Posts: 28
|
|
Hi, i am currently doing a project sort of like a webcrawler. I have a problem in stopping the process after meeting certain criteria. Initially i used system.exit(). But i intend to implement JFrame to run my program, so using system.exit() will also exit the JFrame itself. I did some research online, but i still can't really stop the thread. Knowing that stop() is depreciated, how else can i stop, i am still trying to use the while(status), but doesn't seems to work for me. Thanks~
|
 |
Derek Bright
Greenhorn
Joined: Aug 28, 2008
Posts: 28
|
|
probably to add on a bit, my code is something like this private volatile boolean stopCrawling; while(!stopCrawling){ . . . } even if the stopCrawling eventually becomes true, the thread continues to run...why is it so?
|
 |
Steve Luke
Bartender
Joined: Jan 28, 2003
Posts: 3090
|
|
How do you know that the thread keeps running even though the stopCrawling flag is set to false? To diagnose your problem we will need to see more code. Preferably make a complete, small, self contained version of the application that we could copy and compile ourselves and which shows your problem. Without context we can't really help. An example of a SSCCE that could be used as an example for your work would be: Of course, this will look nothing like your code (probably). But the idea is to simplify your task as much as possible, take out all the code not explicitly related to the problem, and show us the gist of the issue.
|
Steve
|
 |
 |
|
|
subject: Stopping multi-thread
|
|
|