- java.lang.Object
-
- org.snmp4j.util.TaskScheduler
-
- All Implemented Interfaces:
java.lang.Runnable
public class TaskScheduler extends java.lang.Object implements java.lang.Runnable
TheTaskScheduler
uses aThreadPool
to recurrent executeSchedulerTask
s.- Since:
- 1.6
- Version:
- 1.6
- Author:
- Frank Fock
-
-
Field Summary
Fields Modifier and Type Field Description protected long
schedulerTimeout
-
Constructor Summary
Constructors Constructor Description TaskScheduler(ThreadPool threadPool)
Creates aTaskScheduler
that uses the suppliedThreadPool
to execute tasks.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Constructor Detail
-
TaskScheduler
public TaskScheduler(ThreadPool threadPool)
Creates aTaskScheduler
that uses the suppliedThreadPool
to execute tasks.- Parameters:
threadPool
- aThreadPool
.
-
-
Method Detail
-
addTask
public void addTask(SchedulerTask task)
Adds a task to the scheduler.- Parameters:
task
- aSchedulerTask
.
-
removeTask
public boolean removeTask(SchedulerTask task)
Removes a task from the scheduler.- Parameters:
task
- theSchedulerTask
to be removed from the scheduler- Returns:
true
if the task could be removed.
-
clear
public void clear()
Removes all tasks.
-
run
public void run()
Runs the scheduler. While in this method tasks are scheduled on the internal thread pool. The scheduler tries to schedule task fairly.- Specified by:
run
in interfacejava.lang.Runnable
-
setStop
public void setStop(boolean stop)
Stops the schedulers run method.- Parameters:
stop
-true
to stop the scheduler.
-
isStop
public boolean isStop()
Checks if the scheduler is (to be) stopped.- Returns:
true
if the scheduler has been stopped or is being stopped.
-
-