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