[英]Executor thread keeps running after hot deploy
Is there any way to know when a war is being hot deployed so I can shutdown the old executor that is running scheduled tasks? 有没有办法知道战争何时被热部署,所以我可以关闭正在运行计划任务的旧执行器? I'm using jboss 6 and I have a scheduled thread pool that is updating data periodically in the background. 我正在使用jboss 6,我有一个预定的线程池,它在后台定期更新数据。 When I hot deploy that thread pool is not shutdown and new starts up so I have multiple scheduled thread pools. 当我热部署时,该线程池没有关闭并且new启动,所以我有多个预定的线程池。
Thanks for any input. 感谢您的任何意见。
Yes, but it depends on where you start your Executor
and which technology you use: 是的,但这取决于您启动Executor
以及您使用的技术:
in ServletContextListener : start Executor
in contextInitialized()
and shut it down in contextDestroyed()
. 在ServletContextListener中 :在contextInitialized()
启动Executor
并在contextDestroyed()
中将其关闭。
in servlet, start Executor
in init()
, shut it down with destroy()
在servlet中,在init()
启动Executor
,用destroy()
关闭它
in EJB/Spring bean: start in method annotated with @PostConstruct
, shutdown in @PreDestroy
. 在EJB / Spring bean中:从@PostConstruct
注释的方法开始,在@PreDestroy
关闭。
Sure. 当然。 It depends on how do you run this thread. 这取决于你如何运行这个线程。 If for example you are running it from sevlet use servlet's destroy()
method to stop it. 例如,如果您从sevlet运行它,请使用servlet的destroy()
方法来停止它。 If you are using Spring use lifecicle of its Application context. 如果您正在使用其应用程序上下文的Spring使用lifecicle。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.