List<Runnable> () { List<Runnable> queued = new ArrayList<>(myTaskQueue.size()); myTaskQueue.drainTo(queued); for (Runnable fromQueue : queued) { Runnable task = fromQueue instanceof ContextRunnable ? ((ContextRunnable)fromQueue).getDelegate() : fromQueue; if (task instanceof FutureTask && !(task instanceof LastTask)) { ((FutureTask<?>)task).cancel(false); } } return queued; }