由于守护程序线程,Tomcat没有干净地关闭 [英] Tomcat not shutting down cleanly due to daemon threads

查看:621
本文介绍了由于守护程序线程,Tomcat没有干净地关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们运行我们的Web应用程序,我们开始一些Threads用于后台工作以及Quartz。
当我尝试关闭tomcat(在linux上使用shell脚本)时,我总是得到错误,说由于守护程序线程和Quartz线程而无法关闭tomcat。
我们已经尝试了不同的方法来关闭我们的线程(退出run方法)但我们依赖于类的几个静态变量来执行此操作,当我的关闭侦听器获得回调时它变为null

We run our web application wehre we start some Threads for background work and also Quartz. When I try to shutdown tomcat(using shell script on linux), I always get the error saying failed to shutdown tomcat due to daemon threads and Quartz threads. We have tried different ways to shutdown our threads (exit out of run method) but we rely on few static variables of a class to do this which become null by the time my shut down listener gets a callback

是否有一种标准方法可以关闭这种情况下的tomcat?

Is there a standard approach to shut down tomcat for such a scenario?

推荐答案

现在,对于可能的答案(如果您使用Spring),请查看此主题 。如果您使用Spring,可以在Spring的Spring配置中为Quartz添加一个显式的 destroy 子句,以便它可以干净地关闭。

And now for the possible answer (if you use Spring), check out this thread. If you use Spring you can add an explicit destroy clause in your spring config for Quartz so it can shutdown cleanly.

否则一个Servlet监听器(我认为ServletContext监听器,但它已经有一段时间......)可以检测到关机,你可以手动关闭Quartz。

Otherwise a Servlet listener (I think the ServletContext listener, but it has been a while...) can detect shutdown and you can manually shutdown Quartz.

这篇关于由于守护程序线程,Tomcat没有干净地关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆