mx4j.timer

Class TimeTask

public abstract class TimeTask extends Object implements Comparable, Runnable

A task that is executed at a specified time.

Subclasses implement the periodicity, if needed. Two TimeTasks are compared with their neext execution time.

Version: $Revision: 1.3 $

Constructor Summary
protected TimeTask()
Constructor for subclasses
Method Summary
intcompareTo(Object obj)
Compares 2 TimeTasks by comparing their next execution times
booleangetFixedRate()
Returns whether this task is a fixed rate or fixed delay task.
protected longgetNextExecutionTime()
Returns the next time at which the task will be executed, ie the TimeTask method is called.
protected longgetPeriod()
Returns the period of this task.
protected booleanisFinished()
Returns whethere this task is finished.
protected booleanisPeriodic()
Returns whether this task is periodic.
abstract voidrun()
The method to implement to have this TimeTask to do something.
protected voidsetFinished(boolean value)
Marks this task as finished or not.
protected voidsetNextExecutionTime(long time)
Sets the next execution time.

Constructor Detail

TimeTask

protected TimeTask()
Constructor for subclasses

Method Detail

compareTo

public int compareTo(Object obj)
Compares 2 TimeTasks by comparing their next execution times

See Also: TimeTask

getFixedRate

public boolean getFixedRate()
Returns whether this task is a fixed rate or fixed delay task. By default return false

getNextExecutionTime

protected long getNextExecutionTime()
Returns the next time at which the task will be executed, ie the TimeTask method is called.

See Also: TimeTask

getPeriod

protected long getPeriod()
Returns the period of this task. By default returns 0.

See Also: TimeTask

isFinished

protected boolean isFinished()
Returns whethere this task is finished.

See Also: TimeTask

isPeriodic

protected boolean isPeriodic()
Returns whether this task is periodic. By default return false.

See Also: TimeTask

run

public abstract void run()
The method to implement to have this TimeTask to do something.

setFinished

protected void setFinished(boolean value)
Marks this task as finished or not. When a task is finished, its TimeTask method will not be called anymore.

See Also: TimeTask

setNextExecutionTime

protected void setNextExecutionTime(long time)
Sets the next execution time.

See Also: TimeTask

Copyright © 2001-2005 The MX4J Contributors. All Rights Reserved.