public class DefaultTimeScheduler extends java.util.concurrent.ScheduledThreadPoolExecutor implements TimeScheduler
TimeScheduler by extending
ScheduledThreadPoolExecutor to keep tasks sorted. Tasks will get executed in order
of execution time (by using a DelayQueue internally.| 限定符和类型 | 类和说明 |
|---|---|
protected static class |
DefaultTimeScheduler.RobustRunnable
Class which catches exceptions in run() - https://jira.jboss.org/jira/browse/JGRP-1062
|
protected class |
DefaultTimeScheduler.TaskWrapper<V> |
java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicyTimeScheduler.Task| 构造器和说明 |
|---|
DefaultTimeScheduler()
Create a scheduler that executes tasks in dynamically adjustable intervals
|
DefaultTimeScheduler(int corePoolSize) |
DefaultTimeScheduler(ThreadFactory factory) |
DefaultTimeScheduler(ThreadFactory factory,
int max_threads) |
| 限定符和类型 | 方法和说明 |
|---|---|
java.lang.String |
dumpTimerTasks()
Returns a list of tasks currently waiting for execution.
|
int |
getCurrentThreads()
Returns the current threads in the pool, or -1 if not applicable
|
long |
getKeepAliveTime()
Returns the keep alive time (in ms) of the thread pool, or -1 if not applicable
|
int |
getMaxThreads()
Returns the configured max threads, or -1 if not applicable
|
int |
getMinThreads()
Returns the configured core threads, or -1 if not applicable
|
java.util.concurrent.Future<?> |
scheduleWithDynamicInterval(TimeScheduler.Task task)
Schedule a task for execution at varying intervals.
|
java.util.concurrent.ScheduledFuture<?> |
scheduleWithFixedDelay(java.lang.Runnable command,
long initialDelay,
long delay,
java.util.concurrent.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.
|
void |
setKeepAliveTime(long time)
Sets the keep alive time (in ms) of the thread pool.
|
void |
setMaxThreads(int size)
Sets the max pool size.
|
void |
setMinThreads(int size)
Sets the core pool size.
|
void |
setThreadFactory(ThreadFactory factory) |
int |
size()
Answers the number of tasks currently in the queue.
|
void |
stop()
Stop the scheduler if it's running.
|
java.lang.String |
toString() |
decorateTask, decorateTask, execute, getContinueExistingPeriodicTasksAfterShutdownPolicy, getExecuteExistingDelayedTasksAfterShutdownPolicy, getQueue, getRemoveOnCancelPolicy, schedule, schedule, scheduleAtFixedRate, 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, terminatedinvokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskForexecute, isShutdown, schedule, scheduleAtFixedRateprotected static final Log log
public DefaultTimeScheduler()
public DefaultTimeScheduler(ThreadFactory factory)
public DefaultTimeScheduler(ThreadFactory factory, int max_threads)
public DefaultTimeScheduler(int corePoolSize)
public void setThreadFactory(ThreadFactory factory)
setThreadFactory 在接口中 TimeSchedulerpublic java.lang.String dumpTimerTasks()
TimeSchedulerdumpTimerTasks 在接口中 TimeSchedulerpublic int getCurrentThreads()
TimeSchedulergetCurrentThreads 在接口中 TimeSchedulerpublic int getMinThreads()
TimeSchedulergetMinThreads 在接口中 TimeSchedulerpublic void setMinThreads(int size)
TimeSchedulersetMinThreads 在接口中 TimeSchedulerpublic int getMaxThreads()
TimeSchedulergetMaxThreads 在接口中 TimeSchedulerpublic void setMaxThreads(int size)
TimeSchedulersetMaxThreads 在接口中 TimeSchedulerpublic long getKeepAliveTime()
TimeSchedulergetKeepAliveTime 在接口中 TimeSchedulerpublic void setKeepAliveTime(long time)
TimeSchedulersetKeepAliveTime 在接口中 TimeSchedulerpublic java.util.concurrent.Future<?> scheduleWithDynamicInterval(TimeScheduler.Task task)
DefaultTimeScheduler.Task#nextInterval() milliseconds. The task is neve done until nextInterval()
return a value <= 0 or the task is cancelled.scheduleWithDynamicInterval 在接口中 TimeSchedulertask - the task to executerelative - scheduling scheme: true:public java.util.concurrent.ScheduledFuture<?> scheduleWithFixedDelay(java.lang.Runnable command,
long initialDelay,
long delay,
java.util.concurrent.TimeUnit unit)
TimeSchedulerscheduleWithFixedDelay 在接口中 TimeSchedulerscheduleWithFixedDelay 在接口中 java.util.concurrent.ScheduledExecutorServicescheduleWithFixedDelay 在类中 java.util.concurrent.ScheduledThreadPoolExecutorcommand - the task to executeinitialDelay - the time to delay first executiondelay - the delay between the termination of one execution and the commencement of the nextunit - the time unit of the initialDelay and delay parameterspublic int size()
size 在接口中 TimeSchedulerpublic void stop()
stop 在接口中 TimeSchedulerjava.lang.InterruptedException - if interrupted while waiting for thread
to returnpublic java.lang.String toString()
toString 在类中 java.util.concurrent.ThreadPoolExecutor