@Override
    public List<Runnable> shutdownNow() {
        if (!shutdown.compareAndSet(false, true)) {
            return Collections.emptyList();
        }
        List<Runnable> tasks = new LinkedList<>();
        taskQ.drainTo(tasks);
        for (Runnable task : tasks) {
            if (task instanceof RunnableFuture future) {
                future.cancel(false);
            }
        }
        return tasks;
    }
@Test
    public void shutdownNow() throws Exception {
        ManagedExecutorService executorService = newManagedExecutorService();
        CountDownLatch finishLatch = startLongRunningTask(executorService);
        try {

            Future<Object> future = executorService.submit(() -> null);

            List<Runnable> tasks = executorService.shutdownNow();
            assertTrue(executorService.isShutdown());

            assertEquals(1, tasks.size());
            try {
                future.get();
            } catch (CancellationException expected) {
            }
        } finally {
            finishLatch.countDown();
        }
    }