java定时执行任务

ScheduledExecutorService ses = Executors.newScheduledThreadPool(1);
        Runnable command = new Runnable(){
            public void run(){
                System.out.println("start ping ..."+new Date().toLocaleString());
            };
        };
        ses.scheduleAtFixedRate(command, 1, 2, TimeUnit.SECONDS);

 

posted on 2014-05-12 16:05  Love I Smile  阅读(171)  评论(0编辑  收藏  举报