?
Solved

how does shutdown method work in ExecutorService

Posted on 2013-05-16
1
Medium Priority
?
357 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 16

Accepted Solution

by:
Valeri earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

650 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