开发者

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 da开发者_StackOverflow社区ta periodically in the background. When I hot deploy that thread pool is not shutdown and new starts up so I have multiple scheduled thread pools.

Thanks for any input.


Yes, but it depends on where you start your Executor and which technology you use:

  • in ServletContextListener: start Executor in contextInitialized() and shut it down in contextDestroyed().

  • in servlet, start Executor in init(), shut it down with destroy()

  • in EJB/Spring bean: start in method annotated with @PostConstruct, shutdown in @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. If you are using Spring use lifecicle of its Application context.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜