szetszwo commented on PR #6968:
URL: https://github.com/apache/ozone/pull/6968#issuecomment-2246780971

   ```java
     public static void main(String[] args) {
       final int n = 2;
       final CompletableFuture<Integer>[] futures = new CompletableFuture[n];
       CompletableFuture<Integer> all = CompletableFuture.completedFuture(0);
   
       for(int i = 0; i < futures.length; i++) {
         futures[i] = new CompletableFuture<>();
         all = all.thenCombine(futures[i], Integer::sum);
       }
   
       System.out.println("set break point to check objects");
       for(int i = 0; i < futures.length - 1; i++) {
         futures[i].complete(i);
       }
   
       System.out.println("set break point to check objects again");
       final int last = futures.length - 1;
       futures[last].complete(last);
   
       System.out.println("all = " + all.join());
     }
   ```
   Tried the program above.   The `CompletableFuture.thenCombine(..)` 
implementation is smart.  See my next comment.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to