All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----Acme.Task
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:
class Anim implements Runnable
{
public void run()
{
// do an animation frame
}
}
To start this task you would use something like this:
Anim a = new Anim();
Acme.Task t = new Acme.Task( a, 1000 );
Or if, as is likely, your class starts the task in its constructor:
Acme.Task t = new Acme.Task( this, 1000 );
class AnimTask extends Acme.Task
{
public void run()
{
// do an animation frame
}
}
Then you would start it like so:
Acme.Task t = new AnimTask( 1000 );
Fetch the software.
Fetch the entire Acme package.
protected Runnable runnablemsPeriod
protected long msPeriodrunner
protected TaskRunner runnernextRun
protected long nextRun
public Task(long msPeriod)
public Task(Runnable runnable, long msPeriod)
public void run()
public synchronized void deschedule()
All Packages Class Hierarchy This Package Previous Next Index
ACME Java ACME Labs