我有一个问题,这是我的代码片段
executor = Executors.newFixedThreadPool(10);
int count = 0;
while(true){
if(count < 10){
runner = new Runner();
futures.add(executor.submit(runner));
count++;
}
else{
count = 0;
for(f:futures){
while(!f.isDone()){sleep(1000);}
}
executor.shutdown();
executor = Executors.newFixedThreadPool(10);
}
}
跑步者做了有限的工作。当我做的时候
ps -eLf | grep pid | wc -l
我看到了数千个进程的线程,并且cpu负载不断增加。有什么解释吗?