How can I reschedule a timer. I have tried to cancel the timer/timertask and and schedule it again using a method. But its showing an exception error:
Exception errorjava.lang.IllegalStateException: TimerTask is scheduled already
Code I have used it :
private Timer timer = new Timer("alertTimer",true); public void reScheduleTimer(int duration) { timer.cancel(); timer.schedule(timerTask, 1000L, duration * 1000L); }