title: Changing timer interval dynamically in Java 1.4
body: <p>I have a timer task as shown below:</p>
  
  <pre><code>long timerSec = 5000;
  
  TimerTask task1 = new TimerTask()
  {   
      public void run()
      {
          //Some code...
          System.out.println("Timer task...");
      }
  };
  </code></pre>
  
  <p>And a timer object as shown below:</p>
  
  <pre><code>Timer readFileTimer = new Timer();
  </code></pre>
  
  <p>I scheduled a task with 5 secs period between two successive task executions. </p>
  
  <pre><code>readFileTimer.scheduleAtFixedRate(task1, 0, timerSec);
  </code></pre>
  
  <p>Below line of code assigns new time period. I want to change the time period from 5 secs to n-secs (lets say 10 secs w.r.t. timerSec value).</p>
  
  <pre><code>timerSec = CalculateTimeForUpgrade(); //Get new timer interval period.
  </code></pre>
  
  <p>I tried below code, but didn't get the expected result.</p>
  
  <pre><code>readFileTimer.scheduleAtFixedRate(task1, 0, timerSec);
  </code></pre>
  
  <p>Please help. Thanks in advance.</p>