0
타이머 유틸리티를 사용하여 반복적으로 코드 출력을 게시하고 있습니다. 지금은 1 초 간격으로 논스톱으로 반복하도록 설정했습니다. 어떻게하면 사용자가 설정 한 시간 제한에 도달 할 때까지이 방법을 바꿀 수 있습니까?TimerTask를 영구 실행하지 않고 어떻게 제한합니까?
//Create a new timer
Timer timer = new Timer();
static int interval = 1000; //Interval of timer in milliseconds
//Set the timer to start in 1 second and to go every certain amount of milliseconds.
timer.scheduleAtFixedRate(TimerClass.timertask, 1000, interval);
장소 당신은 작업이 시작되었을 때 알고 많은 시간이 경과 된 각 반복 확인하고 제한 시간에 그 비교해야하는'TimerTask' – MadProgrammer
의 종료 조건 가치 – MadProgrammer