UnstoppableScheduledExecutorService implements ScheduledExecutorService { @Override public List<Runnable> shutdownNow() { shutdownLock.writeLock().lock(); try { List<Runnable> runnableList = executorCore.shutdownNow(); cancelPendingTasks(); return runnableList; } finally { shutdownLock.writeLock().unlock(); } } UnstoppableScheduledExecutorService(ScheduledExecutorService executor); @Override ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit); @Override ScheduledFuture<V> schedule(Callable<V> callable, 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 Future<T> submit(Callable<T> task); @Override Future<T> submit(Runnable task, T result); @Override Future<?> submit(Runnable task); @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 void execute(Runnable command); @Override void shutdown(); @Override List<Runnable> shutdownNow(); @Override boolean isShutdown(); @Override boolean isTerminated(); @Override boolean awaitTermination(long timeout, TimeUnit unit);  }
@Test(groups = "fast") public void testShutdownNow() throws Exception { Assert.assertTrue(executor.shutdownNow().isEmpty(), "shutdownNow should return empty list"); Assert.assertFalse(mockExecutor.isShutdown(), "mockExecutor should not be shutdown"); Assert.assertTrue(executor.isShutdown(), "executor should be shut down"); }