Running TimerTask
I want to run TimerTask for fixed number of times. How can i stop the timer after running it certain no of times.
I want to stop my scheduler after running it certain number of times.I am scheduling task as timer.schedule(new MyTask(), Calendar.getInstance().getTime(), 1000);I want my Schedular to stopped after executing 5 Times
> You know how to increment a variable?
I am facing difficulty in Stopping Schedular not in arriving at some condition (Incrementing variable) . So any help in stopping schedular is appreciated.
I am using cancel()
of Timer
class. But, Some thread is running in backgroud and program is not terminating