How to properly catch RuntimeExceptions from Executors?

前端 未结 5 1853
青春惊慌失措
青春惊慌失措 2020-12-12 20:44

Say that I have the following code:

ExecutorService executor = Executors.newSingleThreadExecutor();
executor.execute(myRunnable);

Now, if <

5条回答
  •  星月不相逢
    2020-12-12 21:37

    Why not call ExecutorService#submit(), get the Future back and then handle possible exceptions yourself when calling Future#get() ?

提交回复
热议问题