正如标题所显示,如果的Future.get(超时)超时,并线程继续运行,是否线程继续运行时的Future.get(超时)超时
ExecutorService executor = Executors.newFixedThreadPool(n);
Callable<Object> task = new Callable<Object>() {
public Object call() {
//...
}
}
Future<Object> future = executor.submit(task);
try {
Object result = future.get(5, TimeUnit.SECONDS);
} catch (TimeoutException ex) {
// handle the timeout
}
如果线程继续运行,由于某些IO等原因而被阻塞,那么当线程池变满时,不能新任务被获取,这意味着trheadpool会被卡住,因为池中的所有线程都被阻塞了,对吗?
你试过添加一些I/O来看看会发生什么吗? – 2010-12-08 10:07:49