• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

doubt regarding the ExecutorService shutdown

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic