stackoverflow.com/questions/8498691/pass-parameters-to-timer-task-java
Pass parameters to Timer Task (Java)
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();...
stackoverflow.com
class RegrowCornAnimate extends TimerTask {
private final int serial;
RegrowCornAnimate ( int serial )
{
this.serial = serial;
}
public void run() {
//Do stuff
}
}
...
int i = 0;
while (i < array.size){
Timer timer = new Timer();
timer.schedule(new RegrowCornAnimate( i ), 0, 1000);
i++;
}
...
'시행착오 > [java]' 카테고리의 다른 글
[java] 자바에서 String을 json 객체로 변환 - json-simple 라이브러리 (0) | 2021.04.08 |
---|---|
[java] HTTP request POST 보내는 법 - 예시 코드 / (추가) 한글깨짐 현상 해결 (0) | 2021.04.08 |