concurrent/src/main/java/io/airlift/concurrent/MoreFutures.java
public static <V> ListenableFuture<V> whenAnyComplete(Iterable<? extends ListenableFuture<? extends V>> futures)
    {
        requireNonNull(futures, "futures is null");
        checkArgument(!isEmpty(futures), "futures is empty");

        ExtendedSettableFuture<V> firstCompletedFuture = ExtendedSettableFuture.create();
        for (ListenableFuture<? extends V> future : futures) {
            firstCompletedFuture.setAsync(future);
        }
        return firstCompletedFuture;
    }
public static <V> ListenableFuture<V> whenAnyComplete(Iterable<? extends ListenableFuture<? extends V>> futures)
    {
        requireNonNull(futures, "futures is null");
        checkArgument(!isEmpty(futures), "futures is empty");

        ExtendedSettableFuture<V> firstCompletedFuture = ExtendedSettableFuture.create();
        for (ListenableFuture<? extends V> future : futures) {
            firstCompletedFuture.setAsync(future);
        }
        return firstCompletedFuture;
    }
public static < V > ListenableFuture < V > whenAnyComplete ( Iterable < ? extends ListenableFuture < ? extends V > > futures ) { requireNonNull ( futures , "futures is null" ) ; checkArgument ( ! isEmpty ( futures ) , "futures is empty" ) ; ExtendedSettableFuture < V > firstCompletedFuture = ExtendedSettableFuture . create ( ) ; for ( ListenableFuture < ? extends V > future : futures ) { firstCompletedFuture . setAsync ( future ) ; } return firstCompletedFuture ; }
Creates a future that completes when the first future completes either normally
or exceptionally. Cancellation of the future propagates to the supplied futures.
Creates a future that completes when the first future completes either normally or exceptionally . Cancellation of the future propagates to the supplied futures .