public class SimpleTaskManagerService extends ScheduledThreadPoolExecutor implements TaskManagerService
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy| Modifier and Type | Field and Description |
|---|---|
private AtomicInteger |
taskNum
Used to create a unique identifier for each task
|
| Constructor and Description |
|---|
SimpleTaskManagerService(int corePoolSize) |
| Modifier and Type | Method and Description |
|---|---|
void |
execute(Task task) |
ScheduledFuture |
schedule(Task task,
long delay,
TimeUnit unit)
Creates and executes a one-shot action that becomes enabled after the given delay.
|
ScheduledFuture |
scheduleAtFixedRate(Task task,
long initialDelay,
long period,
TimeUnit unit)
Creates and executes a periodic action that becomes enabled first after
the given initial delay, and subsequently with the given period; that is
executions will commence after initialDelay then initialDelay+period,
then initialDelay + 2 * period, and so on.
|
ScheduledFuture |
scheduleWithFixedDelay(Task task,
long initialDelay,
long delay,
TimeUnit unit)
Creates and executes a periodic action that becomes enabled first after
the given initial delay, and subsequently with the given delay between
the termination of one execution and the commencement of the next.
|
decorateTask, decorateTask, execute, getContinueExistingPeriodicTasksAfterShutdownPolicy, getExecuteExistingDelayedTasksAfterShutdownPolicy, getQueue, getRemoveOnCancelPolicy, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, setContinueExistingPeriodicTasksAfterShutdownPolicy, setExecuteExistingDelayedTasksAfterShutdownPolicy, setRemoveOnCancelPolicy, shutdown, shutdownNow, submit, submit, submitafterExecute, 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, toStringinvokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskForclone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitawaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminatedprivate AtomicInteger taskNum
public void execute(Task task)
execute in interface TaskManagerServicepublic ScheduledFuture schedule(Task task, long delay, TimeUnit unit)
TaskManagerServiceschedule in interface TaskManagerServicetask - The task to be scheduled.delay - Initial delay before the task is executedunit - seconds, milliseconds etc for delaypublic ScheduledFuture scheduleAtFixedRate(Task task, long initialDelay, long period, TimeUnit unit)
TaskManagerServicescheduleAtFixedRate in interface TaskManagerServicetask - The task to be scheduled.initialDelay - Initial delay before the task is first done.period - Fixed period of execution.unit - seconds, milliseconds etc for delay.public ScheduledFuture scheduleWithFixedDelay(Task task, long initialDelay, long delay, TimeUnit unit)
TaskManagerServicescheduleWithFixedDelay in interface TaskManagerServicetask - The task to be scheduled.initialDelay - Initial delay before the task is first done.delay - The delay between each subsequent executionunit - seconds, milliseconds etc for delay.Copyright © 2013. All Rights Reserved.