• Post Reply Bookmark Topic Watch Topic
  • New Topic

doubt regarding the ExecutorService shutdown  RSS feed

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why we write the shutdown in the finally statement? and from the below prog. why the shutdown is first exceuted then the thread opertion is worked but it has to work like  the first the thread operation is performed  then the shutdown
 
author
Marshal
Posts: 23439
138
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Aniket Harode wrote:Why we write the shutdown in the finally statement? and from the below prog. why the shutdown is first exceuted then the thread opertion is worked but it has to work like  the first the thread operation is performed  then the shutdown



Well, it is your code, isn't it? The shutdown() method call is in the finally block because you coded it that way.

As for why the tasks still run, even after shutdown() has been called, it is because it is a graceful shutdown. The tasks in the executor are allowed to complete -- although no new tasks may be added.

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!