|
LimeWire Collection Component API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.limewire.collection.Periodic
public class Periodic
A utility to schedule, reschedule and cancel the execution of a task.
Calendar cal = new GregorianCalendar();
System.out.println("1) " + cal.get(Calendar.SECOND));
Periodic p = new Periodic(new Runnable() {
public void run() {
Calendar cal = new GregorianCalendar();
System.out.println("3) " + cal.get(Calendar.SECOND));
}}, new SimpleTimer(false));
p.rescheduleIfLater(5000);
System.out.println("2) " + cal.get(Calendar.SECOND));
Time run-dependant Output:
1) 23
2) 23
3) 28
| Constructor Summary | |
|---|---|
Periodic(Runnable r,
ScheduledExecutorService scheduler)
Creates a periodic task |
|
| Method Summary | |
|---|---|
protected Runnable |
getRunnable()
|
boolean |
rescheduleIfLater(long newDelay)
changes the execution time of this Periodic task if it is later than the current execution time. |
boolean |
rescheduleIfSooner(long newDelay)
changes the execution time of this Periodic task if it is sooner than the current execution time. |
void |
unschedule()
Cancels any scheduled execution of the task. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Periodic(Runnable r,
ScheduledExecutorService scheduler)
r - the Runnable to executescheduler - the SchedulingThreadPool to schedule
execution on.| Method Detail |
|---|
public boolean rescheduleIfLater(long newDelay)
newDelay - the new delay from now when this should be executed
public boolean rescheduleIfSooner(long newDelay)
newDelay - the new delay from now when this should be executed
public void unschedule()
protected Runnable getRunnable()
|
LimeWire Collection Component API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||