How to use return value from ExecutorService

后端 未结 2 1755
盖世英雄少女心
盖世英雄少女心 2021-01-03 09:14

I am running a for loop under ExecutorService (which sends emails)

If any of the return type is fail , i need to return return resposne as \"Fail\" or else i need to

2条回答
  •  误落风尘
    2021-01-03 09:22

    It seems that you want to wait for the completion of the task that you've submitted (why use an ExecutorService?)

    You can do that by submitting a Callable, the submit method will then return a Future. You can then get() to wait for completion and obtain the result.

提交回复
热议问题