java.util.concurrent.Executor
, java.util.concurrent.ExecutorService
, java.util.concurrent.ScheduledExecutorService
, ThreadManager
public class TimeScheduler extends java.util.concurrent.ScheduledThreadPoolExecutor implements ThreadManager
Modifier and Type | Class | 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 | Description |
---|---|---|
protected static org.apache.commons.logging.Log |
log |
Constructor | 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 | 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.
|
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor
awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
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
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.