简体   繁体   中英

ThreadPool don't run submitted tasks


I have strange problem with java ThreadPool

I'm define executorService as follow:

ExecutorService executorService = Executors.newFixedThreadPool(5)

and later submit tasks:

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 log some debug info including task count:

log.debug("activeCount={}, completedTaskCount={}, taskCount={}. poolSize={}", 
     new Object[] { activeCount, completedTaskCount,taskCount, poolSize });

after running some time (after exected 50-100 task according to thread pool completedTask counter) i'm see strange behavior - submitted tasks appends to pool queue but not executed at all! ThreadPool reported active tasks = 0, task queue size big and counting, and none of tasks executed according to log.
Has someone some problem?

Ok, i'm collect enough statistics to say: this is problem of concrete linux kernel

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

of redhat box. This not reproduced even on 2.4.31 and hihger.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM