public interface TimeScheduler
ScheduledExecutorService
for details
TimeScheduler.Task.nextInterval()
needs to be implemented.
Modifier and Type | Interface and Description |
---|---|
static interface |
TimeScheduler.Task
The interface that dynamic tasks
(
scheduleWithDynamicInterval(org.jgroups.util.TimeScheduler.Task) ) must implement |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
dumpTimerTasks()
Returns a list of tasks currently waiting for execution.
|
void |
execute(java.lang.Runnable command)
Executes command with zero required delay.
|
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
|
boolean |
isShutdown()
Returns true if stop() has been called, false otherwise
|
java.util.concurrent.Future<?> |
schedule(java.lang.Runnable command,
long delay,
java.util.concurrent.TimeUnit unit)
Creates and executes a one-shot action that becomes enabled after the given delay.
|
java.util.concurrent.Future<?> |
scheduleAtFixedRate(java.lang.Runnable command,
long initialDelay,
long period,
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
period; that is executions will commence after
initialDelay then initialDelay+period, then
initialDelay + 2 * period, and so on.
|
java.util.concurrent.Future<?> |
scheduleWithDynamicInterval(TimeScheduler.Task task)
Schedule a task for execution at varying intervals.
|
java.util.concurrent.Future<?> |
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()
Returns the number of tasks currently in the queue.
|
void |
stop()
Stops the scheduler if running, cancelling all pending tasks
|
void execute(java.lang.Runnable command)
command
- the task to executejava.util.concurrent.RejectedExecutionException
- at discretion of RejectedExecutionHandler,
if task cannot be accepted for execution because the executor has been shut down.java.lang.NullPointerException
- if command is nulljava.util.concurrent.Future<?> schedule(java.lang.Runnable command, long delay, java.util.concurrent.TimeUnit unit)
command
- the task to executedelay
- the time from now to delay executionunit
- the time unit of the delay parameterjava.util.concurrent.RejectedExecutionException
- if the task cannot be scheduled for executionjava.lang.NullPointerException
- if command is nulljava.util.concurrent.Future<?> scheduleWithFixedDelay(java.lang.Runnable command, long initialDelay, long delay, java.util.concurrent.TimeUnit unit)
command
- 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 parametersjava.util.concurrent.RejectedExecutionException
- if the task cannot be scheduled for executionjava.lang.NullPointerException
- if command is nulljava.lang.IllegalArgumentException
- if delay less than or equal to zerojava.util.concurrent.Future<?> scheduleAtFixedRate(java.lang.Runnable command, long initialDelay, long period, java.util.concurrent.TimeUnit unit)
command
- the task to executeinitialDelay
- the time to delay first executionperiod
- the period between successive executionsunit
- the time unit of the initialDelay and period parametersjava.util.concurrent.RejectedExecutionException
- if the task cannot be
scheduled for executionjava.lang.NullPointerException
- if command is nulljava.lang.IllegalArgumentException
- if period less than or equal to zerojava.util.concurrent.Future<?> scheduleWithDynamicInterval(TimeScheduler.Task task)
TimeScheduler.Task.nextInterval()
milliseconds. This is delay-based and not
rate-based.
The task is never done until nextInterval() return a value <= 0 or the task is cancelled.task
- the task to executevoid setThreadFactory(ThreadFactory factory)
java.lang.String dumpTimerTasks()
int getMinThreads()
void setMinThreads(int size)
int getMaxThreads()
void setMaxThreads(int size)
long getKeepAliveTime()
void setKeepAliveTime(long time)
int getCurrentThreads()
int size()
void stop()
boolean isShutdown()
Copyright © 1998-2020 Red Hat. All Rights Reserved.