【发布时间】:2016-12-19 20:24:32
【问题描述】:
我是并发新手,我正在尝试为 do-while 循环实现执行器服务并发。但我总是遇到RejectedExecutionException
这是我的示例代码:
do {
Future<Void> future = executor.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
// action
return null;
}
});
futures.add(future);
executor.shutdown();
for (Future<Void> future : futures) {
try {
future.get();
}
catch (InterruptedException e) {
throw new IOException(e)
}
}
}
while (true);
但这似乎不正确。我想我在错误的地方叫停了。谁能帮我正确实现Executor Service in a do-while循环。谢谢。
【问题讨论】:
标签: java multithreading try-catch do-while executorservice