@Override public void run() { try { runnable.run(); } catch (Exception e) { logger.warn("failed to run {}", e, runnable.toString()); } }
@Override public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { if (r instanceof RunnableScheduledFuture) { Object callable = ReflectionUtil.getFieldValue(r, "callable"); Object cfAsync = ReflectionUtil.getFieldValue(callable, "task"); r = (Runnable) cfAsync; } if (r instanceof ForkJoinTask && r.toString().contains("CompletableFuture$Async")) { Field field = ReflectionUtil.getField(r, "dst"); // jdk8u20 if (field == null) { field = ReflectionUtil.getField(r, "dep"); // jdk8u40 } Object dst = ReflectionUtil.getFieldValue(r, field); if (dst instanceof CompletableFuture) { ((CompletableFuture) dst).cancel(false); log.debug("Canceled completable future {}", r); } } else if (r instanceof Future) { ((Future) r).cancel(false); log.debug("Canceled future {}", r); } }
public String toString() { return task.toString(); }
@Override public String toString() { return "[threaded] " + runnable.toString(); }
@Override public String toString() { Runnable task = myTask; return super.toString() + (task != null ? task.toString() : null); }