@Override
    public void afterExecute(final Runnable runnable, final Throwable throwable) {
        super.afterExecute(runnable, throwable);
        if (throwable != null) {
            // Wrap the throwable in an ExecutionException (execute() does not do this)
            interruptionChecker.setExecutionException(new ExecutionException("Uncaught exception", throwable));
            // execute() was called and an uncaught exception or error was thrown
            interruptionChecker.interrupt();
        } else if (/* throwable == null && */ runnable instanceof Future<?>) {
            // submit() was called, so throwable is not set 
            try {
                // This call will not block, since execution has finished
                ((Future<?>) runnable).get();
            } catch (CancellationException | InterruptedException e) {
                // If this thread was cancelled or interrupted, interrupt other threads
                interruptionChecker.interrupt();
            } catch (final ExecutionException e) {
                // Record the exception that was thrown by the thread
                interruptionChecker.setExecutionException(e);
                // Interrupt other threads
                interruptionChecker.interrupt();
            }
        }
    }
@ Override public void afterExecute ( final Runnable runnable , final Throwable throwable ) { super . afterExecute ( runnable , throwable ) ; if ( throwable != null ) { interruptionChecker . setExecutionException ( new ExecutionException ( "Uncaught exception" , throwable ) ) ; interruptionChecker . interrupt ( ) ; } else if ( runnable instanceof Future < ? > ) { try { ( ( Future < ? > ) runnable ) . get ( ) ; } catch ( CancellationException | InterruptedException e ) { interruptionChecker . interrupt ( ) ; } catch ( final ExecutionException e ) { interruptionChecker . setExecutionException ( e ) ; interruptionChecker . interrupt ( ) ; } } }
Catch exceptions from both submit() and execute(), and call {@link InterruptionChecker#interrupt()} to
interrupt all threads.

@param runnable
the Runnable
@param throwable
the Throwable