Java Timer Example

import java.io.IOException;
import java.util.Timer;
public class CheckTimer {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Timer timer = new Timer();
		timer.schedule(new MyTask(), 1000,2000);
		System.out.println("hello");

	}
	
	static class MyTask extends java.util.TimerTask
	{
		@Override
		public void run() {
		// TODO Auto-generated method stub
		System.out.println("____refresh 2 second____");
		}
	}
}

  

posted @ 2012-08-07 16:05  vigarbuaa  阅读(318)  评论(0编辑  收藏  举报