According to documentation, when shutdown()
is invoked, any tasks that were already submitted (I assume via submit()
or execute
) will be executed. When shutdownNow()
is invoked, the executor will halt all tasks waiting to be processed, as well as attempt to stop actively executing tasks.
What I would like to clarify is the exact meaning of "waiting to be processed." For example, say I have an executor, and I call execute()
on some number of Runnable
objects (assume all of these objects effectively ignore interruptions). I know that if I now call shutdown
, all of these objects will finish executing, regardless.
However, if I call shutdownNow
at this point, will it have the same effect as calling shutdown
? Or are some of the objects not executed? In other words, if I want an executor to exit as fast as possible, is my best option always to call shutdownNow()
, even when the Runnables
passed to the executor all effectively ignore interruptions?