Performing a task every x time
<p>I'm trying to perform a task every 5 minute.
The task need to start from: xx:00, xx:05, xx:10, xx:15 and so on so if the time is xx:37 the task will start in xx:40.</p>

<p>I'm used the following code to do that:</p>

<pre><code>    Date d1 = new Date();
    d1.setMinutes(d1.getMinutes() + 5 - d1.getMinutes()%5);
    d1.setSeconds(0);
    this.timer.schedule(new Send(), d1, TEN_MINUTES/2);
</code></pre>

<p>Send looks like that:</p>

<pre><code>class Send extends TimerTask
{
    public void run()
    {
        if(SomeCondition)
                    {
                            Timestamp ts1 = new Timestamp(new java.util.Date().getTime());
                            SendToDB(ts1);
                    }
    }
}
</code></pre>

<p>So the result should be records that if you % the minutes the result would be 0.
But the records time I have is:</p>

<p>*05:35:00
*07:44:40
*07:54:40
*09:05:31
*09:50:00</p>

<p>As you can see the first task start perfectly but then something went wrong.</p>

<p>My guess is that the task calculateds the 5 minute jump after the previous task is finished so the task run time effects, but it's just a guess.</p>
