Below is outtake of unique entries in my Catalina.out file on CentOS machine. I\'m running Tomcat 6 with spring 3 and my application. There is whole bunch of them so I just
Set up a Servlet to manage this in its destroy() method. The threads can check a flag to see if they must continue or not.
In your servlet, do the following in the destroy method. You will obviously need to be able to have access to a Collection but how you get that really depends on how your system is set up.
destroy() {
for (MyThread thread : myThreads) {
thread.stopProcessing();
}
}
Your MyThread class will have something like this:
public class MyThread {
private boolean finished = false;
@Override
public void run() {
while (!finished) {
//do something
}
}
public void stopProcessing() {
finished = true;
}
}