Solved

how does shutdown method work in ExecutorService

Posted on 2013-05-16
1
341 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 …
This video teaches viewers about errors in exception handling.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now