I want to execute a method every second for 20 times.
Actually I have timer
Timer timer = new Timer();
int begin = 0;
int timeInterval = 1000;
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
//call the method
}
}, begin, timeInterval);
How can I call a method 20 times with this interval?