码迷,mamicode.com
首页 > 编程语言 > 详细

定时执行线程池ScheduledExecutorService的使用

时间:2018-06-09 11:40:10      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:LEDE   override   executors   exce   定时   tor   scheduled   TE   begin   

ScheduledExecutorService progressExecutorService = Executors.newScheduledThreadPool(1);
        ScheduledFuture<?> future = progressExecutorService.scheduleAtFixedRate(new Runnable() {// It begins in 0.5 seconds, and executes once every second.
            @Override
            public void run() {
                System.out.println("excel download progress:"+progress.get()+"%");
                if (progress.get() == 100) {
                    System.out.println("excel download progress is 100%");
                    progressExecutorService.shutdown();
                }
            }
        }, (long) 0.5, 1, TimeUnit.SECONDS);

 

定时执行线程池ScheduledExecutorService的使用

标签:LEDE   override   executors   exce   定时   tor   scheduled   TE   begin   

原文地址:https://www.cnblogs.com/shamo89/p/9158660.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!