小编shr*_*wat的帖子

executorService.scheduleAtFixedRate永远运行任务

我想要一个任务在1分钟的间隔后永远运行.为了实现这一点,我写了我的任务

public void poll() {
    ScheduledExecutorService executorService= Executors.newScheduledThreadPool(1);
    ScheduledFuture files=executorService.scheduleAtFixedRate(new Runnable() {      
        @Override
        public void run() {
            String path="/Desktop/PNL/Test";
            List<String> filesPaths= new ArrayList<String>();
            File folder= new File(path);
            File[] listOfFiles= folder.listFiles();
            for (File file : listOfFiles) {
                filesPaths.add(file.getAbsolutePath());
            }
            if(!CollectionUtils.isEmpty(filesPaths)){
                try{
                    update(filesPaths);
                }
                catch(Exception e){
                    System.out.println(e.toString());
                }
            }
        }
    }, 0, 1, TimeUnit.MINUTES);
    files.cancel(false);
    //executorService.shutdown();

}
Run Code Online (Sandbox Code Playgroud)

但是任务只执行一次而不是每分钟后执行.我不明白这里有什么不对.

java concurrency scheduledexecutorservice

6
推荐指数
1
解决办法
4353
查看次数

如何调试swing UI?

我有一个Swing屏幕,我想调试它正在使用哪些服务或框架.之前我曾经在Web应用程序上工作过,我们在firefox mozilla中使用了FireBug来查看UI中使用的内容并导航到服务.我是新手,想知道这个新应用程序是如何使用它的.

java eclipse swing

5
推荐指数
1
解决办法
6606
查看次数

Long.parseLong给出NumberFormatException

我的问题是

checksum = Long.parseLong("-986.9"); 
Run Code Online (Sandbox Code Playgroud)

给出NumberFormatException.这不是很长的吗?

java long-integer

0
推荐指数
1
解决办法
395
查看次数