I have a java Timer and I want it to do something every time it ticks. For example, I want my program to output this:
Output that I want:
Tick 1 seconds passed
Tick 2 seconds passed
Tick 3 seconds passed
Tick 4 seconds passed
Tick 5 seconds passed
Time up, running do_something()...
What I have so far is this:
Timer timer = new Timer();
TimerTask timerTask = new TimerTask() {
@Override
public void run() {
System.out.println("Time up, running do_something()");
do_something();
}
};
timer.schedule(timerTask, 5);
Actual Output of my code so far is this:
Time up, running do_something()...
5 Seconds have passed when I reach this line.