title: Pass parameters to Timer Task (Java)
body: <p>I have a timer task in a loop. I want to pass into the time task which number it is in a loop.</p>
  
  <p>Is that possible?</p>
  
  <p>My code:</p>
  
  <pre><code>...
  int i = 0;
  while (i &lt; array.size){
      Timer timer = new Timer();
      timer.schedule(new RegrowCornAnimate(), 0, 1000);
  i++
  }
  ...
  
  class RegrowCornAnimate extends TimerTask {
       public void run() {
  //Do stuff
     }
  }
  </code></pre>
  
  <p>How can I change it so I can use <code>i</code> in the TimerTask class? -as in each TimerTask will know which <code>i</code> it was created under/in/from.</p>