how does shutdown method work in ExecutorService
Posted on 2013-05-16
Hi, my questions is about how the shutdown method works in ExecutorService.
I can see from the api that:
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?