public class TaskScheduler
extends java.lang.Object
implements java.lang.Runnable
TaskScheduler uses a ThreadPool to recurrent
execute SchedulerTasks.| Modifier and Type | Field and Description |
|---|---|
private static long |
DEFAULT_SCHEDULER_TIMEOUT |
private LogAdapter |
logger |
protected long |
schedulerTimeout |
private boolean |
stop |
private java.util.LinkedList<SchedulerTask> |
tasks |
private ThreadPool |
threadPool |
| Constructor and Description |
|---|
TaskScheduler(ThreadPool threadPool)
Creates a
TaskScheduler that uses the supplied
ThreadPool to execute tasks. |
| Modifier and Type | Method and Description |
|---|---|
void |
addTask(SchedulerTask task)
Adds a task to the scheduler.
|
void |
clear()
Removes all tasks.
|
boolean |
isStop()
Checks if the scheduler is (to be) stopped.
|
boolean |
removeTask(SchedulerTask task)
Removes a task from the scheduler.
|
void |
run()
Runs the scheduler.
|
void |
setStop(boolean stop)
Stops the schedulers run method.
|
private LogAdapter logger
private static final long DEFAULT_SCHEDULER_TIMEOUT
private java.util.LinkedList<SchedulerTask> tasks
private ThreadPool threadPool
private boolean stop
protected long schedulerTimeout
public TaskScheduler(ThreadPool threadPool)
TaskScheduler that uses the supplied
ThreadPool to execute tasks.threadPool - a ThreadPool.public void addTask(SchedulerTask task)
task - a SchedulerTask.public boolean removeTask(SchedulerTask task)
task - the SchedulerTask to be removed from the schedulertrue if the task could be removed.public void clear()
public void run()
run in interface java.lang.Runnablepublic void setStop(boolean stop)
stop - true to stop the scheduler.public boolean isStop()
true if the scheduler has been stopped or is being stopped.