### Question:
CloseableExecutorService implements Closeable { @Override public void close() { isOpen.set(false); Iterator<Future<?>> iterator = futures.iterator(); while ( iterator.hasNext() ) { Future<?> future = iterator.next(); iterator.remove(); if ( !future.isDone() && !future.isCancelled() && !future.cancel(true) ) { log.warn("Could not cancel " + future); } } if (shutdownOnClose) { executorService.shutdownNow(); } } CloseableExecutorService(ExecutorService executorService);  CloseableExecutorService(ExecutorService executorService, boolean shutdownOnClose); boolean isShutdown(); @Override void close(); Future<V> submit(Callable<V> task); Future<?> submit(Runnable task);  }### Answer:
@Test public void testBasicRunnable() throws InterruptedException { try { CloseableExecutorService service = new CloseableExecutorService(executorService); CountDownLatch startLatch = new CountDownLatch(QTY); CountDownLatch latch = new CountDownLatch(QTY); for ( int i = 0; i < QTY; ++i ) { submitRunnable(service, startLatch, latch); } Assert.assertTrue(startLatch.await(3, TimeUnit.SECONDS)); service.close(); Assert.assertTrue(latch.await(3, TimeUnit.SECONDS)); } catch ( AssertionError e ) { throw e; } catch ( Throwable e ) { e.printStackTrace(); } }