I wonder what is correct place to shutdown ExecutorService
in a web application?
According to docs ExecutorService
should be shutdown, but what is correct place in the code to do that in a web application?
UPDATE: Sorry for unclarity. Let's consider under Java EE a web based application with MVC (for instance Spring MVC if that matter). It has Controllers->Facades->Services. It doesnt have EJBs.
"Java EE" covers a wide array of technologies. If you're talking about a servlet, the container will call
destroy()
when it's being shut down, and you could close out yourExecutorService
there. If the service is owned by a managed bean, you could use@PreDestroy
to mark a method to do so.