ITeye博客

Timer

IT009 · 2011-06-30 16:54 · JAVA · 编程语言 · Markdown

public class TimerTasks {

public static void main(String args) {
	Timer time = new Timer();
	Date startDate = new Date();
	TimerTasks task = new TimerTasks();
	final DriectoryManagement dmg = task.new DriectoryManagement();
	time.schedule(new TimerTask() {

		@Override
		public void run() {
			// TODO Auto-generated method stub
			dmg.executes();
		}

	}, startDate, 1000);

	try {
		Thread.sleep(5000);
		time.cancel();
	} catch (InterruptedException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}

public class DriectoryManagement {
	int n;

	public void executes() {
		this.n++;
		System.out.println("n:" + n);
	}
}

}

http://tech.ddvip.com/2008-01/119991257740150_2.html http://my.chinaunix.net/space.php?uid=24426415&do=blog&id=77453 http://www.kklinux.com/html/shujukujishu/BD2/200901/13-2542.html http://database.51cto.com/art/201008/217966.htm

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。