public final class TrackingScheduledExecutor
extends java.util.concurrent.ScheduledThreadPoolExecutor
ScheduledThreadPoolExecutor
with the ability to track
scheduled tasks and cancel them in case a task completes abruptly due to
an exception.
When all the tasks have completed, due to normal termination, or cancelled
due to an exception, the executor invokes a completion handler.java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy
Modifier and Type | Method and Description |
---|---|
protected void |
afterExecute(java.lang.Runnable r,
java.lang.Throwable t)
Invoked by the super class after each task execution.
|
protected <V> java.util.concurrent.RunnableScheduledFuture<V> |
decorateTask(java.util.concurrent.Callable<V> c,
java.util.concurrent.RunnableScheduledFuture<V> task) |
protected <V> java.util.concurrent.RunnableScheduledFuture<V> |
decorateTask(java.lang.Runnable runnable,
java.util.concurrent.RunnableScheduledFuture<V> task) |
boolean |
hasActiveTasks()
Determines whether there are tasks which have started and not completed.
|
static TrackingScheduledExecutor |
newScheduler(java.util.concurrent.ThreadFactory threadFactory,
BiConsumer<java.lang.Object,java.lang.Throwable> completionHandler)
Creates an
TrackingScheduledExecutor using the supplied thread
factory and a completion handler. |
execute, getContinueExistingPeriodicTasksAfterShutdownPolicy, getExecuteExistingDelayedTasksAfterShutdownPolicy, getQueue, getRemoveOnCancelPolicy, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, setContinueExistingPeriodicTasksAfterShutdownPolicy, setExecuteExistingDelayedTasksAfterShutdownPolicy, setRemoveOnCancelPolicy, shutdown, shutdownNow, submit, submit, submit
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, terminated, toString
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor
public static TrackingScheduledExecutor newScheduler(java.util.concurrent.ThreadFactory threadFactory, BiConsumer<java.lang.Object,java.lang.Throwable> completionHandler)
TrackingScheduledExecutor
using the supplied thread
factory and a completion handler.threadFactory
- the thread factory to usecompletionHandler
- handler invoked when all task have completed,
due to normal termination, exception, or cancellation.protected void afterExecute(java.lang.Runnable r, java.lang.Throwable t)
afterExecute
in class java.util.concurrent.ThreadPoolExecutor
protected <V> java.util.concurrent.RunnableScheduledFuture<V> decorateTask(java.lang.Runnable runnable, java.util.concurrent.RunnableScheduledFuture<V> task)
decorateTask
in class java.util.concurrent.ScheduledThreadPoolExecutor
protected <V> java.util.concurrent.RunnableScheduledFuture<V> decorateTask(java.util.concurrent.Callable<V> c, java.util.concurrent.RunnableScheduledFuture<V> task)
decorateTask
in class java.util.concurrent.ScheduledThreadPoolExecutor
public boolean hasActiveTasks()
true
is active tasks exist.Copyright © 2016 The Apache Software Foundation. All Rights Reserved - bbe71fa-20161201-1641