Wait until any of Future is done

前端 未结 8 1085
长发绾君心
长发绾君心 2021-02-01 01:09

I have few asynchronous tasks running and I need to wait until at least one of them is finished (in the future probably I\'ll need to wait util M out of N tasks are finished). C

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-01 01:40

    Why not just create a results queue and wait on the queue? Or more simply, use a CompletionService since that's what it is: an ExecutorService + result queue.

提交回复
热议问题