有人可以帮我解决这个问题。
我在Tomcat 7.0.25上部署了一个spring Web应用程序,在Controller中我创建了如下所示的线程
if(condition == true){
ExecutorService taskExecutor = Executors.newFixedThreadPool(8);
taskExecutor.execute(new SomeRunnable(param1,param2,param3));
//The above execute is repeated 8 times with different params.
taskExecutor.shutdown();
try {
taskExecutor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
} catch (InterruptedException e) {
System.out.println("exception");
}
}
创建了8个任务,并且第一次请求时它会很好地执行。它完成得很好。
现在,当第二次点击上面的代码时,应用程序冻结,使用jvisualvm,我可以看到所有线程都在等待。
有人可以帮我指出为什么第一次它起作用,第二次停止并且tomcat没有响应。
此致