restart timer in java
<p>I would like to do a timer, it will be restarted when  something happens:</p>

<pre><code>public static Timer timer;

public myTimer(long MAC, String ipAddress){
    timer = new Timer();
    timer.schedule(timerTask, 120000); 
}

public void update(){
    timer.cancel();
    timer = new Timer();
    timer.schedule(timerTask, 120000); 
}  
</code></pre>

<p>I have a problem when I create the new schedule, I have this error:</p>

<pre><code>java.lang.IllegalStateException: Task already scheduled or cancelled
    at java.util.Timer.sched(Timer.java:358)
    at java.util.Timer.schedule(Timer.java:170)
    at spb.keepAliveTimer.update(keepAliveTimer.java:37)
    at spb.keepAlive.update(keepAlive.java:58)
    at spb.receptor.keepAlive(receptor.java:475)
    at spb.receptor.run(receptor.java:118)
    at java.lang.Thread.run(Thread.java:662)
</code></pre>

<p>I don't know how can I do it! Thanks!</p>
