What if there was no future.isDone check in the invokeAll method

If we check the invokeAll method in AbstractExecutorService class, then we can see that following things are happening:

  • Submission of the tasks in a for loop
  • Running of another for loop. And in case the future is not completed , then do a get on it (to make sure that all the futures are finished before returning from the invokeAll method)
  • If we check the get method in CompletableFuture, then we see that the get method will return the result immediately if the computation is complete, else will wait until the result is available.

    My question is - is the check in point (2) for checking the completion status using isDone() method of future redundant? Would there be no effect if we remove this check?

    链接地址: http://www.djcxy.com/p/50192.html

    上一篇: 如何判断一个方法是否有使用反射的可变参数?

    下一篇: 如果没有future.isDone,请检查invokeAll方法