If you are interviewing, consider buying our number#1 course for Java Multithreading Interviews.
Overview
ExecutionException
is a checked exception that extends the Exception
class. This exception is thrown by an instance of FutureTask
that encounters an Exception
or Error
(both derivates of Throwable
) that remain unhandled by user code and, subsequently an attempt is made to retrieve the result of such a task.
Example
Consider the program below that has a task submitted to the ExecutorService
. The task simply throws a runtime exception to simulate failure. When we attempt to retrieve the result of the task, the snippet futureTask.get()
throws ExecutionException
.
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy