aspose file tools*
The moose likes Threads and Synchronization and the fly likes What if I don't shutdown the ExecutorService ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "What if I don Watch "What if I don New topic
Author

What if I don't shutdown the ExecutorService ?

Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

Hello,

I'm reviewing some code and found that the ExecutorService's shutdown() method is never called.

The developer tells me that once the webapp (a WAR) is undeployed, it will terminate everything.

Should I be worried about this ?

Regards,

Pho
Daesung Park
Ranch Hand

Joined: Mar 22, 2007
Posts: 68
I prefer to call ExecutorService.shutdownNow() in ServletContextListener.contextDestroyed() to stop worker threads.
These threads can be still alive after tomcat's redeploy.


Daesung Park

BLOG
Alan Mehio
Ranch Hand

Joined: Apr 04, 2005
Posts: 73
Pho Tek wrote:Hello,

I'm reviewing some code and found that the ExecutorService's shutdown() method is never called.

The developer tells me that once the webapp (a WAR) is undeployed, it will terminate everything.

Should I be worried about this ?

Regards,

Pho


When the WAR is undeployed inside a tomcat container or web container, it does not mean the JVM instance has been restarted which means some thread from the Exeuctor Service will still be alived
 
jQuery in Action, 2nd edition
 
subject: What if I don't shutdown the ExecutorService ?