Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of these statements about shutdown() compared with shutdownNow() is correct?

  • A.shutdown() stops running tasks at once, while shutdownNow() waits for them.
  • B.Both methods behave identically; shutdownNow() is simply the newer name.
  • C.shutdown() rejects new tasks but the executor keeps accepting them after shutdownNow().
  • D.shutdown() lets already-submitted tasks finish, while shutdownNow() tries to stop them.

Answer: D

shutdown() is the orderly form: no new tasks are accepted and the queue is drained normally. shutdownNow() also interrupts running tasks and returns the tasks still queued. Neither blocks; waiting for termination is awaitTermination's job.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.