public class MockTimeScheduler extends Object implements TimeScheduler
TimeScheduler, used by unit testsTimeScheduler.Task| Constructor and Description |
|---|
MockTimeScheduler() |
| Modifier and Type | Method and Description |
|---|---|
String |
dumpTimerTasks()
Returns a list of tasks currently waiting for execution.
|
void |
execute(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
|
ThreadDecorator |
getThreadDecorator()
Gets the ThreadDecorator associated with this manager.
|
boolean |
isShutdown()
Returns true if stop() has been called, false otherwise
|
Future<?> |
schedule(Runnable command,
long delay,
TimeUnit unit)
Creates and executes a one-shot action that becomes enabled after the given delay.
|
Future<?> |
scheduleAtFixedRate(Runnable command,
long initialDelay,
long period,
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.
|
Future<?> |
scheduleWithDynamicInterval(TimeScheduler.Task task)
Schedule a task for execution at varying intervals.
|
Future<?> |
scheduleWithFixedDelay(Runnable command,
long initialDelay,
long delay,
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 |
setThreadDecorator(ThreadDecorator decorator)
Sets the ThreadDecorator associated this manager should use.
|
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
|
public void execute(Runnable command)
TimeSchedulerexecute in interface TimeSchedulercommand - the task to executepublic Future<?> schedule(Runnable command, long delay, TimeUnit unit)
TimeSchedulerschedule in interface TimeSchedulercommand - the task to executedelay - the time from now to delay executionunit - the time unit of the delay parameterpublic Future<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
TimeSchedulerscheduleWithFixedDelay in interface TimeSchedulercommand - 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 parameterspublic Future<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)
TimeSchedulerscheduleAtFixedRate in interface TimeSchedulercommand - the task to executeinitialDelay - the time to delay first executionperiod - the period between successive executionsunit - the time unit of the initialDelay and period parameterspublic Future<?> scheduleWithDynamicInterval(TimeScheduler.Task task)
TimeSchedulerTimeScheduler.Task.nextInterval() milliseconds. The task is never done until
nextInterval() return a value <= 0 or the task is cancelled.scheduleWithDynamicInterval in interface TimeSchedulertask - the task to executepublic void setThreadFactory(ThreadFactory factory)
setThreadFactory in interface TimeSchedulerpublic String dumpTimerTasks()
TimeSchedulerdumpTimerTasks in interface TimeSchedulerpublic int getMinThreads()
TimeSchedulergetMinThreads in interface TimeSchedulerpublic void setMinThreads(int size)
TimeSchedulersetMinThreads in interface TimeSchedulerpublic int getMaxThreads()
TimeSchedulergetMaxThreads in interface TimeSchedulerpublic void setMaxThreads(int size)
TimeSchedulersetMaxThreads in interface TimeSchedulerpublic long getKeepAliveTime()
TimeSchedulergetKeepAliveTime in interface TimeSchedulerpublic void setKeepAliveTime(long time)
TimeSchedulersetKeepAliveTime in interface TimeSchedulerpublic int getCurrentThreads()
TimeSchedulergetCurrentThreads in interface TimeSchedulerpublic int size()
TimeSchedulersize in interface TimeSchedulerpublic void stop()
TimeSchedulerstop in interface TimeSchedulerpublic boolean isShutdown()
TimeSchedulerisShutdown in interface TimeSchedulerpublic ThreadDecorator getThreadDecorator()
ThreadManagergetThreadDecorator in interface ThreadManagernull if there is none.public void setThreadDecorator(ThreadDecorator decorator)
ThreadManagersetThreadDecorator in interface ThreadManagerdecorator - the ThreadDecorator, or null.Copyright © 2012 JBoss by Red Hat. All Rights Reserved.