Class Task
public class Task
{
// Methods
public static boolean cancel(int id);
public static int schedule(Runnable runnable);
public static int schedule(Runnable runnable, long when);
public static int schedule(Runnable runnable, long when,
boolean lightweight);
}
This class schedules and manages the execution of runnable objects in the global task manager.
public static boolean cancel(int id);
Cancels a pending runnable object.
Return Value:
Returns true if the runnable object was cancelled successfully; returns false if the task was already run or had never been scheduled.
Parameter | Description |
id
| An integer that identifies the task.
|
public static int schedule(Runnable runnable);
Schedules a runnable object to run immediately in the global task manager as a lightweight task.
Return Value:
Returns a non-zero integer that identifies the task.
Parameter | Description |
runnable
| The object scheduled to run.
|
public static int schedule(Runnable runnable, long when);
Schedules a runnable object to run in the global task manager at the specified time as a lightweight task.
Return Value:
Returns a non-zero integer that identifies the task.
Parameter | Description |
runnable
| The object that is run.
|
when
| The time at which the object is run.
|
public static int schedule(Runnable runnable, long when,
boolean lightweight);
Schedules a runnable object to run in the global task manager at the specified time and optionally as a lightweight task or not.
Return Value:
Returns a non-zero integer that identifies the task.
Parameter | Description |
runnable
| The object that runs.
|
when
| The time at which the object runs.
|
lightweight
| Set to true to run the task as a lightweight task; false, otherwise.
|