public class TaskEngine extends Object
Note: the current implementation of this class ignores priority. This may be changed in the future, however. this is s simple task/job engine, more power see Quartz or JMS usage:
TaskEngine taskEngine = new TaskEngine(); MyTask myTask = new MyTask(); engine.addTask(myTask, Thread.NORM_PRIORITY);MyTask must implements Runnable of Thread.
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
addTask(Runnable r)
Adds a task to the task queue with normal priority.
|
static void |
addTask(Runnable task,
int priority)
Adds a task to the task queue.
|
static TimerTask |
scheduleTask(Runnable task,
int priority,
long delay,
long period)
Schedules a task to periodically run.
|
static TimerTask |
scheduleTask(Runnable task,
long delay,
long period)
Schedules a task to periodically run.
|
public static void addTask(Runnable r)
public static void addTask(Runnable task, int priority)
The priority of the task can be specified and must be one of the following values:
task - the task to executepublic static TimerTask scheduleTask(Runnable task, long delay, long period)
task - task to be scheduled.delay - delay in milliseconds before task is to be executed.period - time in milliseconds between successive task executions.public static TimerTask scheduleTask(Runnable task, int priority, long delay, long period)
task - task to be scheduled.priority - the priority the periodic task should run at.delay - delay in milliseconds before task is to be executed.period - time in milliseconds between successive task executions.Copyright © 2018. All rights reserved.