InterviewSolution
| 1. |
How To Shut Down An Executorservice? |
|
Answer» An ExecutorService can be shut down, which will cause it to reject new tasks. Two DIFFERENT methods are provided for shutting down an ExecutorService. The shutdown() method will allow previously submitted tasks to execute before terminating, while the shutdownNow() method PREVENTS waiting tasks from starting and attempts to stop currently EXECUTING tasks. Upon TERMINATION, an executor has no tasks actively executing, no tasks awaiting execution, and no new tasks can be submitted. An ExecutorService can be shut down, which will cause it to reject new tasks. Two different methods are provided for shutting down an ExecutorService. The shutdown() method will allow previously submitted tasks to execute before terminating, while the shutdownNow() method prevents waiting tasks from starting and attempts to stop currently executing tasks. Upon termination, an executor has no tasks actively executing, no tasks awaiting execution, and no new tasks can be submitted. |
|