Please find my requirement here.I have a InvokeTimer class which invokes TimerClass for every sec/min/hour.In the runnable of TimerClass in need to execute a logic when timer is triggered for every sec i.e if its instance of stats1 and other logic if instance of stats2 if triggered for every minute,similary for an hour.Please help me.How do i do this?
public class TimerClass extends TimerTask{
@Override
public void run() {
if(stats1){
//logic
}else if(stats2){
//logic
}else{
//logic3
}
}
public class InvokeTimer {
TimerClass stats1 = new TimerClass();
TimerClass stats2 = new TimerClass();
TimerClass stats3 = new TimerClass();
Timer timer = new Timer(true);
timer.scheduleAtFixedRate(stats1, 0, 1 * 1000);
timer.scheduleAtFixedRate(stats2, 0, 60 * 1000);
timer.scheduleAtFixedRate(stats3, 0, 24* 60 * 1000);
}