What will happen if the code can't finished on time...
- by Tattat
If I set a timer to execute a code every 3 seconds. If the code isn't finished in 3 seconds, what will happen? The computer will terminal the code or wait for the code finish or continue the timer, and execute the code with the unfinished code concurrently.
int delay = 0; // delay for 0 sec.
int period = 3000; // repeat 3 sec.
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
// Task here ...
// It may take more than 3 sec to finish, what will happen?
}
}, delay, period);