简体   繁体   中英

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM