|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.concurrent.AbstractExecutorService
java.util.concurrent.ThreadPoolExecutor
java.util.concurrent.ScheduledThreadPoolExecutor
org.jgroups.util.TimeScheduler
public class TimeScheduler
Fixed-delay & fixed-rate single thread scheduler
The scheduler supports varying scheduling intervals by asking the task every time for its next preferred scheduling interval. Scheduling can either be fixed-delay or fixed-rate. The notions are borrowed from java.util.Timer and retain the same meaning. I.e. in fixed-delay scheduling, the task's new schedule is calculated as:
Nested Class Summary | |
---|---|
static interface |
TimeScheduler.Task
The interface that submitted tasks must implement |
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor |
---|
java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy |
Field Summary | |
---|---|
protected static org.apache.commons.logging.Log |
log
|
Constructor Summary | |
---|---|
TimeScheduler()
Create a scheduler that executes tasks in dynamically adjustable intervals |
|
TimeScheduler(int corePoolSize)
|
|
TimeScheduler(ThreadFactory factory)
|
|
TimeScheduler(ThreadFactory factory,
int max_threads)
|
Method Summary | |
---|---|
protected void |
afterExecute(java.lang.Runnable r,
java.lang.Throwable t)
|
java.lang.String |
dumpTaskQueue()
|
ThreadDecorator |
getThreadDecorator()
Gets the ThreadDecorator associated with this manager. |
java.util.concurrent.ScheduledFuture<?> |
scheduleWithDynamicInterval(TimeScheduler.Task t)
Add a task for execution at adjustable intervals |
java.util.concurrent.ScheduledFuture<?> |
scheduleWithDynamicInterval(TimeScheduler.Task task,
boolean relative)
Schedule a task for execution at varying intervals. |
void |
setThreadDecorator(ThreadDecorator threadDecorator)
Sets the ThreadDecorator associated this manager should use. |
int |
size()
Answers the number of tasks currently in the queue. |
void |
start()
Start the scheduler, if it's suspended or stopped |
void |
stop()
Stop the scheduler if it's running. |
Methods inherited from class java.util.concurrent.ScheduledThreadPoolExecutor |
---|
decorateTask, decorateTask, execute, getContinueExistingPeriodicTasksAfterShutdownPolicy, getExecuteExistingDelayedTasksAfterShutdownPolicy, getQueue, remove, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, setContinueExistingPeriodicTasksAfterShutdownPolicy, setExecuteExistingDelayedTasksAfterShutdownPolicy, shutdown, shutdownNow, submit, submit, submit |
Methods inherited from class java.util.concurrent.ThreadPoolExecutor |
---|
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, terminated |
Methods inherited from class java.util.concurrent.AbstractExecutorService |
---|
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.concurrent.ExecutorService |
---|
awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated |
Field Detail |
---|
protected static final org.apache.commons.logging.Log log
Constructor Detail |
---|
public TimeScheduler()
public TimeScheduler(ThreadFactory factory)
public TimeScheduler(ThreadFactory factory, int max_threads)
public TimeScheduler(int corePoolSize)
Method Detail |
---|
public ThreadDecorator getThreadDecorator()
ThreadManager
getThreadDecorator
in interface ThreadManager
null
if there is none.public void setThreadDecorator(ThreadDecorator threadDecorator)
ThreadManager
setThreadDecorator
in interface ThreadManager
threadDecorator
- the ThreadDecorator, or null
.public java.lang.String dumpTaskQueue()
public java.util.concurrent.ScheduledFuture<?> scheduleWithDynamicInterval(TimeScheduler.Task task, boolean relative)
TimeScheduler.Task.nextInterval()
milliseconds. The task is neve done until nextInterval()
return a value <= 0 or the task is cancelled.
task
- the task to executerelative
- scheduling scheme: true:public java.util.concurrent.ScheduledFuture<?> scheduleWithDynamicInterval(TimeScheduler.Task t)
t
- the task to executepublic int size()
public void start()
public void stop() throws java.lang.InterruptedException
java.lang.InterruptedException
- if interrupted while waiting for thread
to returnprotected void afterExecute(java.lang.Runnable r, java.lang.Throwable t)
afterExecute
in class java.util.concurrent.ThreadPoolExecutor
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |