Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What if I don't shutdown the ExecutorService ?

 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I prefer to call ExecutorService.shutdownNow() in ServletContextListener.contextDestroyed() to stop worker threads.
These threads can be still alive after tomcat's redeploy.
 
Alan Mehio
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic