Catching thread exceptions from Java ExecutorService

后端 未结 6 1113
闹比i
闹比i 2020-12-30 04:18

I\'m working on a software development framework for parallel computing JavaSeis.org. I need a robust mechanism for reporting thread exceptions. During development, knowing

6条回答
  •  忘掉有多难
    2020-12-30 04:27

    As explained in this thread What is the difference between submit and execute method with ThreadPoolExecutor, using execute will only work if you implement Runnable and not Callable as execute cannot return a Future.

    I think in your scenario you should build the future object so that it can accommodate the exception stuff also. So in case of exception you build the error message object.

提交回复
热议问题