java定时循环执行简单示例

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class TestMain {
   
    public static void main (String [] args) throws CDREParsexception{

        Runnable runnable = new Runnable(){
            public void run(){
                System.out.println("hello!!!!");
            }
        };

        ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
        service.scheduleAtFixedRate(runnable, 0, 3, TimeUnit.SECONDS);
    } 
}

猜你喜欢

转载自sanry.iteye.com/blog/2305861
今日推荐