@Override
    public synchronized void stop() throws Exception {
        if (isStopping.compareAndSet(false, true)) {
            if (isPaused.get()) {
                // We need to release the blocked threads so the executor can shut down
                resume();
            }
            LOGGER.info("Stopping parallel executor '{}', threadCount: {}",
                    threadNamePrefix, threadCount);
            final DurationTimer timer = DurationTimer.start();
            executorService.shutdownNow();
            final boolean didTerminate = executorService.awaitTermination(1, TimeUnit.DAYS);
            LOGGER.info("Stopped parallel executor '{}', threadCount: {}, didTerminate: {}, duration: {}",
                    threadNamePrefix, threadCount, didTerminate, timer);
            isStopped.set(true);
        } else {
            throw new IllegalStateException(LogUtil.message(
                    "Attempt to stop parallel executor '{}' when it is already stopped or shutting down.",
                    threadNamePrefix));
        }
    }
If true, pause the executor's threads after they have completed their current task.
if false, resume all the executor's threads.
If already in the desired state, is a noop.
stroom-proxy/stroom-proxy-repo/src/main/java/stroom/proxy/repo/ParallelExecutor.java