2011-01-25 57 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上也沒有這樣的複製。