When you submit a task to the executor, it returns you a FutureTask
instance.
FutureTask.get()
will re-throw any exception thrown by the task as an ExecutorException
.
So when you iterate through the List<Future>
and call get on each, catch ExecutorException
and invoke an orderly shutdown.
More Related Contents:
- Handling exceptions from Java ExecutorService tasks
- Executors.newCachedThreadPool() versus Executors.newFixedThreadPool()
- Impossible to make a cached thread pool with a size limit?
- What’s the difference between Thread start() and Runnable run()
- Why must wait() always be in synchronized block
- ExecutorService that interrupts tasks after a timeout
- Volatile vs Static in Java
- When would you call java’s thread.run() instead of thread.start()?
- How to get the ThreadPoolExecutor to increase threads to max before queueing?
- What are the main uses of yield(), and how does it differ from join() and interrupt()?
- How to properly use Java Executor?
- What are the advantages of using an ExecutorService?
- What’s a monitor in Java?
- Java threads and number of cores
- When should I use a CompletionService over an ExecutorService?
- Forcing multiple threads to use multiple CPUs when they are available
- Simplest and understandable example of volatile keyword in Java
- ThreadPoolExecutor Block When Queue Is Full?
- Why does Java not see the updated value from another thread?
- Who is calling the Java Thread interrupt() method if I’m not?
- Why does java.util.concurrent.ArrayBlockingQueue use ‘while’ loops instead of ‘if’ around calls to await()?
- What is adaptive spinning w.r.t lock acquisition?
- Thread Confinement
- How can I wrap a method so that I can kill its execution if it exceeds a specified timeout?
- What is the most frequent concurrency issue you’ve encountered in Java? [closed]
- Java, divide incoming work uniformly via hashing in multithreaded evnironments
- CopyOnWriteArrayList throwing CurrentModificationException
- Dynamic Thread Pool
- Will a chain of method calls (CompletableFuture API) execute asynchronously if the first method in a chain is asynchronous?
- ExecutorCompletionService? Why do need one if we have invokeAll?