I have a Timer class to response of SMS continuously.
public class MyRegularTask extends TimerTask {
public void run() {
Thread.sleep(1000);
answerLeftSMS();
// this.cancel(); I do not cancel this Timer
}
}
Currently I am running it by a action call.
Timer time = new Timer();
MyRegularTask taskTimer = new MyRegularTask();
time.schedule(taskTimer, 0, 60000);
Is there any way to run this timer automatically, when I start Application Server (Tomcat, Glassfish) ? I am using Spring MVC (Annotation).