首页 > 编程语言 > 详细

定时执行线程池ScheduledExecutorService的使用

时间:2018-06-09 10:59:42      阅读:230      评论:0      收藏:0      [点我收藏+]
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的使用

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!