Solved

how does shutdown method work in ExecutorService

Posted on 2013-05-16
1
347 Views
Last Modified: 2013-05-16
Hi, my questions is about how the shutdown method works in ExecutorService.
I can see from the api that:
shutdown()
          Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.

In the implementation i see it calls the shutdown method which disables new tasks from being submitted, then it calls shutdownNow()which cancels currently executing tasks.

My question is, what exactly happens to threads that are in execution when that happens? what if i have a thread responsible for placing a order to buy or sell or a thread responsible for delivering something to a router, what will happen to it if the shutdown method is called in this case?

Thanks
0
Comment
Question by:Squadless
1 Comment
 
LVL 16

Accepted Solution

by:
Valeri earned 500 total points
ID: 39171676
if you call only "shutdown()" then current tasks will be finished and then ExecutorService will exit.
see this, it will give you more information how to shutdown ExecutorService gracefully:
http://thelifeofajavadeveloper.blogspot.com/2012/03/how-to-shutdown-executorservice.html
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question