@Override protected <T> PrioritizedListenableFutureTask<T> newTaskFor(Runnable runnable, T value) { Preconditions.checkArgument( allowRegularTasks || runnable instanceof PrioritizedRunnable, "task does not implement PrioritizedRunnable"); return PrioritizedListenableFutureTask.create( ListenableFutureTask.create(runnable, value), runnable instanceof PrioritizedRunnable ? ((PrioritizedRunnable) runnable).getPriority() : defaultPriority); }
@Override protected <T> PrioritizedListenableFutureTask<T> newTaskFor(Callable<T> callable) { Preconditions.checkArgument( allowRegularTasks || callable instanceof PrioritizedCallable, "task does not implement PrioritizedCallable"); return PrioritizedListenableFutureTask.create( ListenableFutureTask.create(callable), callable instanceof PrioritizedCallable ? ((PrioritizedCallable) callable).getPriority() : defaultPriority); }
@Override public int compareTo(PrioritizedListenableFutureTask otherTask) { return -Ints.compare(getPriority(), otherTask.getPriority()); }