Take the 2-minute tour ×  I have developed a multithreaded web
application that runs in Tomcat. But I cannot use   Tomcat
didn't stop gracefully. In the debugger I saw that threads
continue to run after shutdown command. Do I have to fix my
application code to meet special requirements ? Thanks.
share|improve this question  3 Answers 3  up vote 11 down vote
accepted  ... and to tie the other responses to the workings of
Java Servlet environments;  if you don't declare your threads as
daemon threads, the way to signal the server shutdown to the
threads is to implement a ServletContextListener and configure
it to your web application (web.xml). When Tomcat is shutting
down, it will first shut down each application, which in turn
will cause contextDestroyed() method of the listener to be
called - and this is where you can signal your own threads that
they should finish ther work.  share|improve this answer  You
need to cancel your threads, preferably by calling interrupt on
them and making sure they are written