What will happen if the code can't finished on time...
Posted
by Tattat
on Stack Overflow
See other posts from Stack Overflow
or by Tattat
Published on 2010-04-06T16:59:10Z
Indexed on
2010/04/06
17:03 UTC
Read the original article
Hit count: 173
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);
© Stack Overflow or respective owner