What is the outcome of calling the get() method on Future if the task is canceled?

  • It returns the result of the task.
  • It throws a CancellationException.
  • It throws an ExecutionException.
  • It throws an InterruptedException.
When you call the get() method on a Future and the associated task is canceled, it throws a CancellationException. This exception indicates that the task was canceled before it could complete. It is important to catch this exception when working with Future objects to handle canceled tasks gracefully.
Add your answer
Loading...

Leave a comment

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