public class TimeScheduler extends java.util.concurrent.ScheduledThreadPoolExecutor implements ThreadManager
Modifier and Type | Class and Description |
---|---|
static interface |
TimeScheduler.Task
The interface that submitted tasks must implement
|
java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy
Modifier and Type | Field and Description |
---|---|
protected static org.apache.commons.logging.Log |
log |
Constructor and Description |
---|
TimeScheduler()
Create a scheduler that executes tasks in dynamically adjustable intervals
|
TimeScheduler(int corePoolSize) |
TimeScheduler(ThreadFactory factory) |
TimeScheduler(ThreadFactory factory,
int max_threads) |
Modifier and Type | Method and Description |
---|---|
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.
|
decorateTask, decorateTask, 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 TimeScheduler()
public TimeScheduler(ThreadFactory factory)
public TimeScheduler(ThreadFactory factory, int max_threads)
public TimeScheduler(int corePoolSize)
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
Copyright ? 1998-2008 Bela Ban. All Rights Reserved.