简体   繁体   English

热部署后,执行程序线程继续运行

[英]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.

相关问题 主类完成后,执行器线程继续运行 - Executor thread keeps running after main class is finished 如何在运行后标识线程,然后使用executor插件在Grails中将其停止? - How to identify a thread after running and then stop it in Grails with the executor plugin? java rabbitmq with Executor thread,创建的线程保持运行。 如何确保线程被杀死? - java rabbitmq with Executor thread, created threads keeps running. how to make sure threads are killed? 等待执行后关闭执行器线程 - Shutdown Executor thread after awaitConfimation 应用程序线程保持运行 - Application thread keeps running 即使在Websphere中停止了应用程序之后,线程仍保持运行 - Thread keeps running even after application has been stopped in Websphere Java执行程序模型,仅允许在实例化线程上运行任务 - Java executor model that allows running tasks only on instantiating thread 执行器服务RabbitMQ中只有一个线程并发运行 - Only one thread is running concurrently in executor service, RabbitMQ 从执行程序服务停止正在运行的线程的优雅方法是什么? - What is the elegant way to Stop a running thread from executor service 在 Hazelcast(嵌入式)执行程序服务线程运行时防止 JVM 关闭 - Prevent JVM Shutdown while Hazelcast(Embedded) executor service thread is running
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM