Should threads have special design to be shutdown gracefully by Tomcat?

前端 未结 3 2236
滥情空心
滥情空心 2021-02-19 11:57

I have developed a multithreaded web application that runs in Tomcat. But I cannot use

shutdown.bat

Tomcat didn\'t stop gracefully. In the deb

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-19 12:50

    Any threads that are still running will keep the Java (Tomcat) process alive. Make sure all your threads exit. Once your threads exit, Tomcat will be able to shut down.

    See the javadoc for Thread. Note the following:

    The Java Virtual Machine continues to execute threads until either of the following occurs:

    • The exit method of class Runtime has been called and the security manager has permitted the exit operation to take place.
    • All threads that are not daemon threads have died, either by returning from the call to the run method or by throwing an exception that propagates beyond the run method.

提交回复
热议问题