|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ccg.util.ScheduleEntry
public abstract class ScheduleEntry
Base implementation of a Schedulable entry.
This class implements all of the basic functions necessary of a
Schedulable interface. It simplifies the task of creating a
periodic event. You simply extend this class, implement the run() method and add it to a Scheduler. The Scheduler will then take care of invoking your method on a
periodic basis (note, your run() method should run rather
quickly - if it might block, or take a long time, you should
consider running it as its own separate thread).
Scheduler| Constructor Summary | |
|---|---|
ScheduleEntry()
Default constructor. |
|
ScheduleEntry(int delayMillis)
Construct a ScheduleEntry object with a initial delay. |
|
| Method Summary | |
|---|---|
int |
getDelayMillis()
Get delay (in milliseconds) between runs. |
abstract void |
run()
What should be done periodically. |
void |
setDelayMillis(int delayMillis)
Set the delay time until the run() method is invoked. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ScheduleEntry()
ScheduleEntry object initializing
its delay time to 1000 milliseconds. If the object is added to a
Scheduler its run() method will be invoked once a
second (approximately).
setDelayMillis(int),
ScheduleEntry(int)public ScheduleEntry(int delayMillis)
ScheduleEntry object with a initial delay.
This method creates a ScheduleEntry object initializing
its delay time to the number of milliseconds specified. If the
object is added to a Scheduler its run() method
will be invoked once the specified number of milliseconds have
elapsed (approximately).
delayMillis - How long in milliseconds before the run() method should
be invoked.setDelayMillis(int),
ScheduleEntry()| Method Detail |
|---|
public int getDelayMillis()
Schedulable objects must provide a run()
method. These run() methods are similar to threads except the
run() method should never block or run indefinitely (it should do
something fairly quickly and then exit). This method indicates
how much of a delay (in milliseconds) there should be before the
Scheduler invokes the run() method. This allows one to
control how often the Schedulable item is run. This time
should remain constant until the setDelayMillis(int) method
is invoked.
getDelayMillis in interface SchedulableSchedulable objects run method. Return 0 if you no longer
need to continue running (you will then be removed from the
Scheduler's table of Schedulable objects).setDelayMillis(int),
Schedulerpublic void setDelayMillis(int delayMillis)
run() method is invoked.
This method is used to set the delay (in milliseconds) that the
Scheduler will wait to invoke the run() method of
this object. It should be noted, that if you adjust this value
from a thread outside of the Scheduler, the value won't
take affect until after the schedular next invokes your
run() method.
delayMillis - How long in milliseconds before the run() method should
be invoked.getDelayMillis()public abstract void run()
Schedulable interface and
ScheduleEntry classes. After this item has been added to a Scheduler, the Scheduler will periodically invoke this method. The delays
between invocations are determined by getDelayMillis().
NOTE: Since the Scheduler object may manage
many Schedulable objects, it is important that this
method execute as quickly as possible - since it blocks the
execution of all other objects maintained by the Scheduler. If your object might block indefinitely (say waiting
for input), or loop indefinitely, or do anything else which might
cause it to take a long time, it should not be added to a shared
Scheduler.
run in interface RunnableScheduler
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||