All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Acme.Task

java.lang.Object
   |
   +----Acme.Task

public class Task
extends Object
implements Runnable
A periodic action.

A Task represents a bit of code that you want to run repeatedly at equally-timed intervals. Doing the timing yourself via sleeps is either inaccurate, since it depends on how long the task takes to run, or else complicated. Well, this class does the timing accurately but hides the complexity from you.

Tasks use the Runnable interface, just like Threads. This means that just like with Threads, there are two different ways you can create a Task:

Fetch the software.
Fetch the entire Acme package.


Variable Index

 o msPeriod
 o nextRun
 o runnable
 o runner

Constructor Index

 o Task(long)
Constructor for subclasses that override run().
 o Task(Runnable, long)
Constructor with a Runnable specified.

Method Index

 o deschedule()
Stops a Task from running in the future.
 o run()
The body of the Task.

Variables

 o runnable
 protected Runnable runnable
 o msPeriod
 protected long msPeriod
 o runner
 protected TaskRunner runner
 o nextRun
 protected long nextRun

Constructors

 o Task
 public Task(long msPeriod)
Constructor for subclasses that override run().

 o Task
 public Task(Runnable runnable,
             long msPeriod)
Constructor with a Runnable specified.

Methods

 o run
 public void run()
The body of the Task. You must either override this method by subclassing class Task, or you must create the Task with a Runnable target.

 o deschedule
 public synchronized void deschedule()
Stops a Task from running in the future.


All Packages  Class Hierarchy  This Package  Previous  Next  Index

ACME Java  ACME Labs