### Question:
InterruptingExecutor implements ScheduledExecutorService { @Override public void shutdown() { myShutdown = true; myOvertimeGuard.setCancelAfterNextRun(); if (myExecutor instanceof ExecutorService) { ((ExecutorService)myExecutor).shutdown(); } } InterruptingExecutor(Executor wrappedExecutor, long timeLimitMilliseconds); @Override boolean awaitTermination(long timeout, TimeUnit unit); @Override synchronized void execute(Runnable command); @Override List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks); @Override List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit); @Override T invokeAny(Collection<? extends Callable<T>> tasks); @Override T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit); @Override boolean isShutdown(); @Override boolean isTerminated(); @Override ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit); @SuppressWarnings("cast") @Override ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit); @Override ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit); @Override ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit); @Override void shutdown(); @Override List<Runnable> shutdownNow(); @Override Future<T> submit(Callable<T> task); @SuppressWarnings("cast") @Override Future<?> submit(Runnable task); @Override Future<T> submit(Runnable task, T result);  }### Answer:
@Test public void testShutdown() { Executor wrappedExecutor = Executors.newFixedThreadPool(1); long timeLimitMilliseconds = 100000L; InterruptingExecutor exec = new InterruptingExecutor(wrappedExecutor, timeLimitMilliseconds); RunnableImplementation command = new RunnableImplementation(timeLimitMilliseconds, 0L); exec.execute(command); ThreadUtilities.sleep(50L); exec.shutdownNow(); ThreadUtilities.sleep(50L); Assert.assertEquals("Command should have been interrupted once.", 1, command.getInterruptedCount()); }