TimeScheduler3
instead@Deprecated public class TimeScheduler2 extends java.lang.Object implements TimeScheduler, java.lang.Runnable
TimeScheduler
. Uses a thread pool and a single thread which waits for the
next task to be executed. When ready, it passes the task to the associated pool to get executed. When multiple tasks
are scheduled to get executed at the same time, they're collected in a queue associated with the task execution
time, and are executed together.Modifier and Type | Class and Description |
---|---|
protected static class |
TimeScheduler2.MyTask
Deprecated.
Simple task wrapper, always executed by at most 1 thread.
|
TimeScheduler.Task
Modifier and Type | Field and Description |
---|---|
protected static Log |
log
Deprecated.
|
protected java.util.concurrent.atomic.AtomicBoolean |
no_tasks
Deprecated.
Needed to signal going from 0 tasks to non-zero (we cannot use tasks.isEmpty() here ...)
|
protected boolean |
running
Deprecated.
|
protected static long |
SLEEP_TIME
Deprecated.
|
protected ThreadFactory |
timer_thread_factory
Deprecated.
|
Constructor and Description |
---|
TimeScheduler2()
Deprecated.
Create a scheduler that executes tasks in dynamically adjustable intervals
|
TimeScheduler2(int corePoolSize)
Deprecated.
|
TimeScheduler2(ThreadFactory factory,
int min_threads,
int max_threads,
long keep_alive_time,
int max_queue_size,
java.lang.String rejection_policy)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_run()
Deprecated.
|
java.lang.String |
dumpTimerTasks()
Deprecated.
Returns a list of tasks currently waiting for execution.
|
void |
execute(java.lang.Runnable task)
Deprecated.
Executes command with zero required delay.
|
int |
getCurrentThreads()
Deprecated.
Returns the current threads in the pool, or -1 if not applicable
|
long |
getKeepAliveTime()
Deprecated.
Returns the keep alive time (in ms) of the thread pool, or -1 if not applicable
|
int |
getMaxThreads()
Deprecated.
Returns the configured max threads, or -1 if not applicable
|
int |
getMinThreads()
Deprecated.
Returns the configured core threads, or -1 if not applicable
|
int |
getQueueSize()
Deprecated.
|
protected void |
init()
Deprecated.
|
boolean |
isShutdown()
Deprecated.
Returns true if stop() has been called, false otherwise
|
void |
run()
Deprecated.
|
java.util.concurrent.Future<?> |
schedule(java.lang.Runnable work,
long delay,
java.util.concurrent.TimeUnit unit)
Deprecated.
Creates and executes a one-shot action that becomes enabled after the given delay.
|
java.util.concurrent.Future<?> |
scheduleAtFixedRate(java.lang.Runnable task,
long initial_delay,
long delay,
java.util.concurrent.TimeUnit unit)
Deprecated.
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)
Deprecated.
Schedule a task for execution at varying intervals.
|
java.util.concurrent.Future<?> |
scheduleWithFixedDelay(java.lang.Runnable task,
long initial_delay,
long delay,
java.util.concurrent.TimeUnit unit)
Deprecated.
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)
Deprecated.
Sets the keep alive time (in ms) of the thread pool.
|
void |
setMaxThreads(int size)
Deprecated.
Sets the max pool size.
|
void |
setMinThreads(int size)
Deprecated.
Sets the core pool size.
|
void |
setThreadFactory(ThreadFactory f)
Deprecated.
|
int |
size()
Deprecated.
Returns the number of tasks currently in the timer
|
protected void |
startRunner()
Deprecated.
|
void |
stop()
Deprecated.
Stops the timer, cancelling all tasks
|
protected void |
stopRunner()
Deprecated.
|
protected void |
taskReady(long trigger_time)
Deprecated.
Signals that a task with a lower execution time than next_execution_time is ready
|
java.lang.String |
toString()
Deprecated.
|
protected void |
waitFor()
Deprecated.
|
protected void |
waitUntilNextExecution()
Deprecated.
Sleeps until the next task in line is ready to be executed
|
protected final java.util.concurrent.atomic.AtomicBoolean no_tasks
protected volatile boolean running
protected static final Log log
protected ThreadFactory timer_thread_factory
protected static final long SLEEP_TIME
public TimeScheduler2()
public TimeScheduler2(ThreadFactory factory, int min_threads, int max_threads, long keep_alive_time, int max_queue_size, java.lang.String rejection_policy)
public TimeScheduler2(int corePoolSize)
public void setThreadFactory(ThreadFactory f)
setThreadFactory
in interface TimeScheduler
public int getMinThreads()
TimeScheduler
getMinThreads
in interface TimeScheduler
public void setMinThreads(int size)
TimeScheduler
setMinThreads
in interface TimeScheduler
public int getMaxThreads()
TimeScheduler
getMaxThreads
in interface TimeScheduler
public void setMaxThreads(int size)
TimeScheduler
setMaxThreads
in interface TimeScheduler
public long getKeepAliveTime()
TimeScheduler
getKeepAliveTime
in interface TimeScheduler
public void setKeepAliveTime(long time)
TimeScheduler
setKeepAliveTime
in interface TimeScheduler
public int getCurrentThreads()
TimeScheduler
getCurrentThreads
in interface TimeScheduler
public int getQueueSize()
public java.lang.String dumpTimerTasks()
TimeScheduler
dumpTimerTasks
in interface TimeScheduler
public void execute(java.lang.Runnable task)
TimeScheduler
execute
in interface TimeScheduler
task
- the task to executepublic java.util.concurrent.Future<?> schedule(java.lang.Runnable work, long delay, java.util.concurrent.TimeUnit unit)
TimeScheduler
schedule
in interface TimeScheduler
work
- the task to executedelay
- the time from now to delay executionunit
- the time unit of the delay parameterpublic java.util.concurrent.Future<?> scheduleWithFixedDelay(java.lang.Runnable task, long initial_delay, long delay, java.util.concurrent.TimeUnit unit)
TimeScheduler
scheduleWithFixedDelay
in interface TimeScheduler
task
- the task to executeinitial_delay
- 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 java.util.concurrent.Future<?> scheduleAtFixedRate(java.lang.Runnable task, long initial_delay, long delay, java.util.concurrent.TimeUnit unit)
TimeScheduler
scheduleAtFixedRate
in interface TimeScheduler
task
- the task to executeinitial_delay
- the time to delay first executiondelay
- the period between successive executionsunit
- the time unit of the initialDelay and period parameterspublic java.util.concurrent.Future<?> scheduleWithDynamicInterval(TimeScheduler.Task task)
TimeScheduler2.RecurringTask.nextInterval()
milliseconds. The task is never done until nextInterval()
return a value <= 0 or the task is cancelled.scheduleWithDynamicInterval
in interface TimeScheduler
task
- the task to execute
Task is rescheduled relative to the last time it actually started execution
false:public int size()
size
in interface TimeScheduler
public java.lang.String toString()
toString
in class java.lang.Object
public void stop()
stop
in interface TimeScheduler
java.lang.InterruptedException
- if interrupted while waiting for thread to returnpublic boolean isShutdown()
TimeScheduler
isShutdown
in interface TimeScheduler
public void run()
run
in interface java.lang.Runnable
protected void _run()
protected void init()
protected void waitUntilNextExecution()
protected void waitFor()
protected void taskReady(long trigger_time)
protected void startRunner()
protected void stopRunner()
Copyright © 1998-2020 Red Hat. All Rights Reserved.