@Test public void testShutdownNow() throws InterruptedException { ExecutorService pool = new StripedExecutorService(); Object stripe = new Object(); AtomicInteger actual = new AtomicInteger(0); for (int i = 0; i < 100; i++) { pool.submit(new TestRunnable(stripe, actual, i)); } Thread.sleep(500); assertFalse(pool.isTerminated()); Collection<Runnable> unfinishedJobs = pool.shutdownNow(); assertTrue(pool.isShutdown()); assertTrue(pool.awaitTermination(1, TimeUnit.MINUTES)); assertTrue(pool.isTerminated()); assertTrue(unfinishedJobs.size() > 0); assertEquals(100, unfinishedJobs.size() + actual.intValue()); }
public List<Runnable> shutdownNow() { lock.lock(); try { shutdown(); List<Runnable> result = new ArrayList<>(); for (SerialExecutor ser_ex : executors.values()) { ser_ex.tasks.drainTo(result); } result.addAll(executor.shutdownNow()); return result; } finally { lock.unlock(); } }
StripedExecutorService extends AbstractExecutorService { public List<Runnable> shutdownNow() { lock.lock(); try { shutdown(); List<Runnable> result = new ArrayList<>(); for (SerialExecutor ser_ex : executors.values()) { ser_ex.tasks.drainTo(result); } result.addAll(executor.shutdownNow()); return result; } finally { lock.unlock(); } } }
StripedExecutorService extends AbstractExecutorService { public List<Runnable> shutdownNow() { lock.lock(); try { shutdown(); List<Runnable> result = new ArrayList<>(); for (SerialExecutor ser_ex : executors.values()) { ser_ex.tasks.drainTo(result); } result.addAll(executor.shutdownNow()); return result; } finally { lock.unlock(); } } private  StripedExecutorService(ExecutorService executor);  StripedExecutorService();  StripedExecutorService(int numberOfThreads); }
StripedExecutorService extends AbstractExecutorService { public List<Runnable> shutdownNow() { lock.lock(); try { shutdown(); List<Runnable> result = new ArrayList<>(); for (SerialExecutor ser_ex : executors.values()) { ser_ex.tasks.drainTo(result); } result.addAll(executor.shutdownNow()); return result; } finally { lock.unlock(); } } private  StripedExecutorService(ExecutorService executor);  StripedExecutorService();  StripedExecutorService(int numberOfThreads); Future<?> submit(Runnable task); Future<T> submit(Runnable task, T result); Future<T> submit(Callable<T> task); void execute(Runnable command); void shutdown(); List<Runnable> shutdownNow(); boolean isShutdown(); boolean isTerminated(); boolean awaitTermination(long timeout, TimeUnit unit); String toString(); int numberOfExecutors(); Map<String, Integer> serialExecutorQueueSizes(); }
StripedExecutorService extends AbstractExecutorService { public List<Runnable> shutdownNow() { lock.lock(); try { shutdown(); List<Runnable> result = new ArrayList<>(); for (SerialExecutor ser_ex : executors.values()) { ser_ex.tasks.drainTo(result); } result.addAll(executor.shutdownNow()); return result; } finally { lock.unlock(); } } private  StripedExecutorService(ExecutorService executor);  StripedExecutorService();  StripedExecutorService(int numberOfThreads); Future<?> submit(Runnable task); Future<T> submit(Runnable task, T result); Future<T> submit(Callable<T> task); void execute(Runnable command); void shutdown(); List<Runnable> shutdownNow(); boolean isShutdown(); boolean isTerminated(); boolean awaitTermination(long timeout, TimeUnit unit); String toString(); int numberOfExecutors(); Map<String, Integer> serialExecutorQueueSizes();  }