i need to run the following code for only 60 seconds
the code works prefect with delay for 2 sec and repeat every 5 seconds..
but here i need to do this all for 60 seconds only
int delay = 3000; // delay for 3 sec.
int period = 5000; // repeat every 5 sec.
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
System.out.println("Would it run?"+System.currentTimeMillis());
}
}, delay, period);
Please let me know how to do this?
You can do it simply with a
ScheduledExecutorService:ScheduledFuture