Servlet on startup that triggers an event after regular interval of time using timer class?
<p>I have a servlet that starts on start of tomcat. I need a functionality in that servlet that triggers the event after a regular interval of time i.e 1 hour and
runs in the back ground? Here  is my  code :-</p>

<p>in main method </p>

<pre><code>MyTask contentTask = new MyTask();
 long interval = 60 * 60 * 1000;
Timer timer = new Timer();
timer.schedule(contentTask, new Date(), interval);//line 1
 System.out.println("line2");//line2
</code></pre>

<p>MyTask</p>

<pre><code>public class MyTask extends TimerTask {
 @Override
 public void run() {
System.out.println("Inside my task");

}
}
</code></pre>

<p>i am expecting as soon control comes to line 2 , run method gets executed and then it keeps on execting the task after ever 60 minutes like background thread does. But
    control does not come to  run method after line 2. <strong>I am not sure what i am missing here and why run method is not getting executed?</strong></p>

<p><strong>Edit:-  I think problem is with interval value if i make it one minute i.e 1 * 60 * 1000; contol comes to run method . Looks like even the first time task will be executed after specified time interval  i.e 60 minutes but i want to execute the task immediately as soon as it executes the line 1 and then repeat it after 60 minutes How to go for this?</strong> </p>
