|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--org.webmacro.util.TimeLoop
TimeLoop is a scheduler which can schedule Runnable objects for execution or repeate execution. A TimeLoop is configured with two key parameters: periods and duration.
You can schedule a job to execute once, P periods from now, where P must be less than the number of periods in the TimeLoop.
You can also schedule a job to execute once every P periods, where P must be less than the number of periods in the timeloop. TimeLoop will be somewhat inaccurate in this case unless the number of periods in the TimeLoop is a multiple of P: otherwise it cannot distribute the repeat job evenly over its time periods.
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
TimeLoop(long duration,
int periods)
Create a new TimeLoop. |
Method Summary | |
static void |
main(java.lang.String[] arg)
Test the TimeLoop |
void |
run()
Do not call this method. |
void |
schedule(java.lang.Runnable task,
int waitPeriods)
Schedule a job to run in the specified number of waitPeriods. |
void |
scheduleRepeat(java.lang.Runnable task,
int waitPeriods)
Schedule a task to run repeatedly, once every waitPeriods. |
void |
scheduleRepeatTime(java.lang.Runnable task,
long milliseconds)
A convenience method which translates your milliseconds into wait periods. |
void |
scheduleTime(java.lang.Runnable task,
long milliseconds)
A convenience method which translates your milliseconds into wait periods. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public TimeLoop(long duration, int periods)
duration
- how long is each period? (milliseconds)periods
- how many periods are there in total?Method Detail |
public java.lang.String toString()
toString
in class java.lang.Thread
public void run()
run
in class java.lang.Thread
public void scheduleRepeat(java.lang.Runnable task, int waitPeriods)
public void scheduleRepeatTime(java.lang.Runnable task, long milliseconds)
public void schedule(java.lang.Runnable task, int waitPeriods)
public void scheduleTime(java.lang.Runnable task, long milliseconds)
public static void main(java.lang.String[] arg)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |