I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 3a57310f authored by dev's avatar dev
Browse files

SimpleTimer2: Call the 3-arg addPeridicEvenet() from the 2-arg addPeridicEvenet()

parent f5ba1b1b
No related branches found
No related tags found
No related merge requests found
...@@ -131,13 +131,15 @@ public class SimpleTimer2 { ...@@ -131,13 +131,15 @@ public class SimpleTimer2 {
* @param event * @param event
* @param timeoutMs * @param timeoutMs
*/ */
public void addEvent(final SimpleTimer.TimedEvent event, long timeoutMs) { public void addEvent(final SimpleTimer.TimedEvent event, final long timeoutMs) {
if (event == null) if (event == null)
throw new IllegalArgumentException("addEvent null"); throw new IllegalArgumentException("addEvent null");
new TimedEvent(this, timeoutMs) { new TimedEvent(this, timeoutMs) {
long absTime = System.currentTimeMillis() + timeoutMs;
@Override @Override
public void timeReached() { public void timeReached() {
System.out.println("Event scheduled for: " + absTime + " started at: " + System.currentTimeMillis() + ", diff: " + (System.currentTimeMillis() - absTime));
event.timeReached(); event.timeReached();
} }
}; };
...@@ -152,17 +154,10 @@ public class SimpleTimer2 { ...@@ -152,17 +154,10 @@ public class SimpleTimer2 {
* its own rescheduling). * its own rescheduling).
* *
* @since 0.9.20 * @since 0.9.20
* @param delay run the first iteration of this event after delay ms
* @param timeoutMs run subsequent iterations of this event every timeoutMs ms * @param timeoutMs run subsequent iterations of this event every timeoutMs ms
*/ */
public void addPeriodicEvent(final SimpleTimer.TimedEvent event, final long timeoutMs) { public void addPeriodicEvent(final SimpleTimer.TimedEvent event, final long timeoutMs) {
addPeriodicEvent(event, timeoutMs, timeoutMs);
new PeriodicTimedEvent(this, timeoutMs, timeoutMs) {
@Override
public void timeReached() {
event.timeReached();
}
};
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment