We are deploying application in WebSphere cluster. Application is running his own never terminated threads that are checking some condition for example:
while(true){
logger.severe("Unterminated thread");
Thread.sleep(10000);
}
Problem is that after the application is stop(via wsadmin or admin console) in the WebSphere, only the servlets are unregistrated but
these threads are not kill and are still running. Is there any way how to kill this treads when i am stopping the application? We are using WebSphere 7.
thanks
Based on your comments to another answer, I have a suggestion. (Note, I agree with Oleg that you really shouldn’t be doing it this way, but if you must…).
I presume that in the regular Java application that this code is from, these background threads somehow receive a signal to stop. What I would suggest is using a
ServletContextListenerto send the stop signal when your servlets have all been deregistered.Note that if you don’t already have some way to tell the threads to stop, that’s probably another bug, and this won’t help at all.