So I'm trying to schedule a time instance where it repeats every 10 seconds. Right now I have something that does a task after 10 seconds, but how do I make it so that it resets after doing so.
this.schedule = TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
chrs.get(0).getMap().spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(100100), chrs.get(0).getPosition());
}
}, time);
}
time is equal to 10000 milliseconds, and thus 10 seconds.
1) Create ScheduledExecutorService
2) Create and schedule your Runnable:
If you don't care about runnable duration and always want to fire event every 10 secs
3) Use this when you exit program