Java Thread Future transferResult(final CompletionStage source, final CompletableFuture target)

Here you can find the source of transferResult(final CompletionStage source, final CompletableFuture target)

Description

transfer Result

License

Apache License

Declaration

public static <T> void transferResult(final CompletionStage<T> source, final CompletableFuture<T> target) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.concurrent.CompletableFuture;

import java.util.concurrent.CompletionStage;

public class Main {
    public static <T> void transferResult(final CompletionStage<T> source, final CompletableFuture<T> target) {
        source.whenComplete((result, throwable) -> {
            final boolean isSuccessful = throwable == null;
            if (isSuccessful) {
                target.complete(result);
            } else {
                target.completeExceptionally(throwable);
            }/*  www . ja  va  2 s . c  om*/
        });
    }
}

Related

  1. sequence(List> futures)
  2. sequence(List> futures)
  3. sequence(List> futures)
  4. submitTasks(ExecutorCompletionService ecs, Iterable> tasks)
  5. sumFutures(List> futures)
  6. transferResult(final CompletionStage source, final CompletableFuture target)
  7. unwrap(Throwable throwable, Class throwableA)
  8. waitFor(Future future)
  9. waitForAll(List> futures)