Notice
Recent Posts
Recent Comments
CrashOverride 잡동사니 !!
Java :: Timer 본문
import java.util.Timer;
import java.util.TimerTask;
public class time {
Timer timer;
public time(int seconds) {
timer = new Timer();
timer.schedule(new TimerTaskTest(), seconds*1000);
}
class TimerTaskTest extends TimerTask {
public void run() {
System.out.println("Time's up!");
timer.cancel(); //timer thread 종료
}
}
public static void main(String args[]) {
System.out.println("About to schedule task.");
new time(10);
System.out.println("Task scheduled.");
}
}
10초가 될경우 타이머가 종료 된다!!!
출처 :: Holic's Tistory
http://holiclove.tistory.com/entry/자바-타이머
'Dev > Java' 카테고리의 다른 글
Mac OS X Lion :: 이클립스의 오류표시 문제 (0) | 2011.08.30 |
---|---|
Java :: 형변환 (0) | 2009.09.22 |
Java :: 날짜 계산 (0) | 2009.09.22 |
Comments