@Test public void testShutdown() throws InterruptedException { ThreadGroup group = new ThreadGroup("stripetestgroup"); Thread starter = new Thread(group, "starter") { public void run() { 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)); } pool.shutdown(); } }; starter.start(); starter.join(); for (int i = 0; i < 100; i++) { if (group.activeCount() == 0) { return; } Thread.sleep(100); } assertEquals(0, group.activeCount()); }
public void shutdown() { lock.lock(); try { state = State.SHUTDOWN; if (executors.isEmpty()) { executor.shutdown(); } } finally { lock.unlock(); } }
StripedExecutorService extends AbstractExecutorService { public void shutdown() { lock.lock(); try { state = State.SHUTDOWN; if (executors.isEmpty()) { executor.shutdown(); } } finally { lock.unlock(); } } }
StripedExecutorService extends AbstractExecutorService { public void shutdown() { lock.lock(); try { state = State.SHUTDOWN; if (executors.isEmpty()) { executor.shutdown(); } } finally { lock.unlock(); } } private  StripedExecutorService(ExecutorService executor);  StripedExecutorService();  StripedExecutorService(int numberOfThreads); }
StripedExecutorService extends AbstractExecutorService { public void shutdown() { lock.lock(); try { state = State.SHUTDOWN; if (executors.isEmpty()) { executor.shutdown(); } } 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 void shutdown() { lock.lock(); try { state = State.SHUTDOWN; if (executors.isEmpty()) { executor.shutdown(); } } 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();  }