public class SimpleTimer2 extends Object
Modifier and Type | Class and Description |
---|---|
static class |
SimpleTimer2.TimedEvent
Similar to SimpleTimer.TimedEvent but users must extend instead of implement,
and all schedule and cancel methods are through this class rather than SimpleTimer2.
|
Modifier | Constructor and Description |
---|---|
|
SimpleTimer2(I2PAppContext context)
To be instantiated by the context.
|
protected |
SimpleTimer2(I2PAppContext context,
String name)
To be instantiated by the context.
|
protected |
SimpleTimer2(I2PAppContext context,
String name,
boolean prestartAllThreads)
To be instantiated by the context.
|
Modifier and Type | Method and Description |
---|---|
void |
addEvent(SimpleTimer.TimedEvent event,
long timeoutMs)
Queue up the given event to be fired no sooner than timeoutMs from now.
|
void |
addPeriodicEvent(SimpleTimer.TimedEvent event,
long timeoutMs)
Schedule periodic event
The TimedEvent must not do its own rescheduling.
|
void |
addPeriodicEvent(SimpleTimer.TimedEvent event,
long delay,
long timeoutMs)
Schedule periodic event
The TimedEvent must not do its own rescheduling.
|
static SimpleTimer2 |
getInstance()
If you have a context, use context.simpleTimer2() instead
|
void |
stop()
Stops the SimpleTimer.
|
String |
toString() |
public SimpleTimer2(I2PAppContext context)
protected SimpleTimer2(I2PAppContext context, String name)
protected SimpleTimer2(I2PAppContext context, String name, boolean prestartAllThreads)
public static SimpleTimer2 getInstance()
public void stop()
public void addEvent(SimpleTimer.TimedEvent event, long timeoutMs)
event
- to be run oncetimeoutMs
- run after this delaypublic void addPeriodicEvent(SimpleTimer.TimedEvent event, long timeoutMs)
timeoutMs
- run subsequent iterations of this event every timeoutMs ms, 5000 minimumIllegalArgumentException
- if timeoutMs less than 5000public void addPeriodicEvent(SimpleTimer.TimedEvent event, long delay, long timeoutMs)
delay
- run the first iteration of this event after delay mstimeoutMs
- run subsequent iterations of this event every timeoutMs ms, 5000 minimumIllegalArgumentException
- if timeoutMs less than 5000