定时执行线程池ScheduledExecutorService的使用
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);