java简单计时器

简单计时器:

import java.util.Timer;

importjava.util.TimerTask;

public class Timer_test {

    public static void main(String[]args) {

        Timer time =new Timer();

        time.schedule(new Start(), 0,1000); //启动计时器 //1秒调用一次

    }

}

class Start extends TimerTask{

    int i = 0;

    public void run(){

        i++;

        System.out.println("输出第:"+i+" ");

    }

}

你可能感兴趣的:(java)