0
我需要使用任何Executor
或ExecutorService
执行任务。任务(Callable
或Runnable
)应该无限运行,但如果发生任何异常,应该将其重新提交给提交任务的线程。重新引发异常的ExecutorService
我知道future.get()
会抛出ExecutionException
对我来说:
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<?> future = executor.submit(new Task());
future.get();
然而,在晴天的情况我就future.get()
无限期地阻塞,所以我不能使用它。
有可能有任何Executor
只是当底层任务失败时抛出异常?