SCJA Done
SCJP Done
SCJD URLybird 1.3.1 Passed
martin naughton wrote:
java.util.concurrent.ThreadPoolExecutor
public void shutdown()
Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. Invocation has no additional effect if already shut down.
I have searched all over the internet. I trying to understand by what they mean by "submitted task". Is it when all the task in pool will be finished and everything in the queue will be discarded or is it everything submitted in the queue will be finished including what is in the queue at the time the shutdown command is given?
martin naughton wrote:
Also await seems to only wait until all the tasks that were in the pool are finished. it does not care if any tasks are in the queue.
public boolean awaitTermination(long timeout,
TimeUnit unit)
throws InterruptedException
Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.
Does the threadpoolexecutor api support waiting for queue to be empty before shutting down? or do you have to implement a wait for the queue to be empty before calling shutdown yourself.
Yes. Previous submitted tasks are tasks submitted into the pool prior to the shutdown call. And they will be executed before the pool threads terminates.
This method simply waits for termination -- whether termination occurs after the queue is drained or not depends on whether you requested an orderly shutdown or not.
SCJA Done
SCJP Done
SCJD URLybird 1.3.1 Passed
martin naughton wrote:
Yes. Previous submitted tasks are tasks submitted into the pool prior to the shutdown call. And they will be executed before the pool threads terminates.
So that means then that any thing in the queue is discarded. Understand
SCJA Done
SCJP Done
SCJD URLybird 1.3.1 Passed
We're all out of roofs. But we still have tiny ads:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|