public class BasicScheduledTaskService extends WWObjectImpl implements ScheduledTaskService, Thread.UncaughtExceptionHandler
| Modifier and Type | Class and Description |
|---|---|
protected class |
BasicScheduledTaskService.ScheduledTaskExecutor
Custom executor to run tasks.
|
| Modifier and Type | Field and Description |
|---|---|
protected ConcurrentLinkedQueue<Runnable> |
activeTasks
Tasks currently running.
|
protected static int |
DEFAULT_POOL_SIZE
Default thread pool size.
|
protected BasicScheduledTaskService.ScheduledTaskExecutor |
executor
Executor for running tasks.
|
protected static String |
IDLE_THREAD_NAME_PREFIX
Name assigned to idle threads.
|
protected static String |
RUNNING_THREAD_NAME_PREFIX
Name assigned to active threads.
|
| Constructor and Description |
|---|
BasicScheduledTaskService()
Create a new scheduled task service.
|
| Modifier and Type | Method and Description |
|---|---|
ScheduledFuture<?> |
addRepeatingTask(Runnable runnable,
long initialDelay,
long period,
TimeUnit timeunit)
Enqueues a task to run periodically.
|
ScheduledFuture<?> |
addScheduledTask(Runnable runnable,
long delay,
TimeUnit timeunit)
Enqueues a task to run after a delay.
|
void |
addTask(Runnable runnable)
Enqueues a task to run.
|
void |
shutdown(boolean immediately)
Shut down the service.
|
void |
uncaughtException(Thread thread,
Throwable throwable) |
onMessage, propertyChangeaddPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValuesclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValuesprotected ConcurrentLinkedQueue<Runnable> activeTasks
protected static final int DEFAULT_POOL_SIZE
protected BasicScheduledTaskService.ScheduledTaskExecutor executor
protected static final String IDLE_THREAD_NAME_PREFIX
protected static final String RUNNING_THREAD_NAME_PREFIX
public BasicScheduledTaskService()
AVKey.TASK_POOL_SIZE.public ScheduledFuture<?> addRepeatingTask(Runnable runnable, long initialDelay, long period, TimeUnit timeunit)
ScheduledExecutorService.scheduleAtFixedRate(java.lang.Runnable, long, long, java.util.concurrent.TimeUnit). Duplicate tasks are ignored.addRepeatingTask in interface ScheduledTaskServicerunnable - the task to add.initialDelay - delay before the first execution of the task. timeUnit determines the units of the
value.period - interval between executions of the task. timeUnit determines the units of the value.timeunit - time unit of initialDelay and period.null if
the task was not enqueued.public ScheduledFuture<?> addScheduledTask(Runnable runnable, long delay, TimeUnit timeunit)
addScheduledTask in interface ScheduledTaskServicerunnable - the task to add.delay - delay before execution of the task. timeUnit determines the units of the value.timeunit - time unit of initialDelay and period.null if
the task was not enqueued.public void addTask(Runnable runnable)
addTask in interface ScheduledTaskServicerunnable - the task to addpublic void shutdown(boolean immediately)
ScheduledTaskServiceimmediate parameter is true, the service will attempt to stop all
active tasks, and will not begin work on any other tasks in the queue. Otherwise, the service will complete all
tasks in the work queue, but will not accept any new tasks.shutdown in interface ScheduledTaskServiceimmediately - true to shutdown immediately.public void uncaughtException(Thread thread, Throwable throwable)
uncaughtException in interface Thread.UncaughtExceptionHandler