2011-01-25 154 views
4


我有奇怪的问题,用java线程池线程池不跑提交的任务

我定义的ExecutorService如下:

ExecutorService executorService = Executors.newFixedThreadPool(5) 

后来提交任务:

while (!manager.stop()) { 
    File file = getFile(); 
    if (file != null) { 
     String name = file.getName(); 
     log.debug("add new task with name {}", name); 
     outExecutorInfo(); 
     Future<?> task = executorService.submit(getTask(file)); 
     outTaskInfo(task); 
     executeTasks.put(name, task); 
     outExecuteTasks(); 
    } 
} 

outExecuteTasks记录一些调试信息,包括任务数:

提交任务追加到池队列,但不是在所有执行 -

运行一段时间后,我看到我奇怪的行为(根据线程池completedTask柜台后exected 50-100任务)! ThreadPool报告活动任务= 0,任务队列大小很大并且计数,并且没有任何任务根据日志执行。
有人遇到问题吗?

+0

可能是Java中的一个错误。您使用的是最新版本的JRE吗? – 2011-01-25 06:44:55

回答

2

好吧,我要收集足够的统计数字,说:这是具体的Linux内核

[[email protected]]$ uname -a 
Linux ns.mag 2.4.20-8smp #1 SMP Thu Mar 13 17:45:54 EST 2003 i686 i686 i386 GNU/Linux 
红帽箱

的问题。甚至在2.4.31和hihger上也没有这样的复制。