自动任务

public class Tim {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        final int time = 3000;
        Runnable runnable = new Runnable(){
            public void run(){
                while (true){
                System.out.println("自动任务");
                
                try {
                    Thread.sleep(time);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                }
            }
        };
        Thread thread = new Thread(runnable);
        thread.start();
    }

}
 

猜你喜欢

转载自blog.csdn.net/hei__ke/article/details/89355576