How can we gracefully shutdown an ExecutorService?

  • Call shutdown()
  • Call shutdown() and then shutdownNow()
  • Call shutdownNow() and then shutdown()
  • Call stop()
To gracefully shut down an ExecutorService, you should first call the shutdown() method, which initiates an orderly shutdown, allowing previously submitted tasks to execute before terminating. You should not call shutdownNow() before shutdown() because it forcefully attempts to stop all executing tasks. The other options are incorrect for a graceful shutdown.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *