显示使用线程池Executors,必须执行 pool.shutdown() 否则会存在线程池泄露;
http://stackoverflow.com/questions/22650569/spring-webapp-shutting-down-threads-on-application-stop
I am instantiating a ScheduledExecutorService using Spring's ApplicationListener interface as follows:
At the moment, Tomcat won't shut down cleanly when I run, ./shutdown.sh, with message:
and this seems to be because I have not yet written code to stop the ScheduledExecutorService. My question is: how should this be done properly in this environment? I noticed that there exists a ContextStoppedEvent, so, I implemented a listener for it:
But it seems that this event handler doesn't get called when Tomcat is shutdown. Have I implemented this incorrectly, or am I going about this completely the wong way? |
|||
add a comment
|
You're looking for
When the Servlet container shuts down, it calls |
|||
preDestroy
could work here too. – Sotirios Delimanolis Aug 27 '14 at 14:24