public static CompletionStage < Void > allOf ( CompletionStage < Void > first , CompletionStage < Void > second ) { if ( ! isCompletedSuccessfully ( first ) ) { if ( isCompletedSuccessfully ( second ) ) { return first ; } else { return CompletionStages . aggregateCompletionStage ( ) . dependsOn ( first ) . dependsOn ( second ) . freeze ( ) ; } } return second ; }
Returns a CompletableStage that completes when both of the provides CompletionStages complete . This method may choose to return either of the argument if the other is complete or a new instance completely .