Java – ExecutionException

ExecutionException: Thrown when attempting to retrieve the result of a task that aborted by throwing an exception.
Example:

ExecutorService executor = Executors.newSingleThreadExecutor();
Future future = executor.submit(() -> {
throw new IllegalStateException("Execution Error");
});
try {
future.get();
} catch (ExecutionException e) {
System.out.println("Caught ExecutionException: " + e.getMessage());
}

No images available.