Java Thread Future convertFuture(Future future)

Here you can find the source of convertFuture(Future future)

Description

convert Future

License

Apache License

Declaration

public static <V> CompletableFuture<V> convertFuture(Future<V> future) 

Method Source Code


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

import java.util.concurrent.CompletableFuture;

import java.util.concurrent.Future;

import static java.util.concurrent.CompletableFuture.supplyAsync;

public class Main {
    public static <V> CompletableFuture<V> convertFuture(Future<V> future) {
        CompletableFuture<V> brighterFuture = supplyAsync(() -> {
            try {
                return future.get();
            } catch (Exception e1) {
                throw new RuntimeException(e1);
            }/*from   w w w.j a v a 2  s . c  o  m*/
        });
        return brighterFuture;
    }
}

Related

  1. cancel(List> futures)
  2. cancelNullableFutures(boolean mayInterruptIfRunning, Iterable> futures)
  3. cancelScheduledFuture(ScheduledFuture scheduledFuture)
  4. checkTimeThresholds(long expectedMin, long expectedMax, long expectedOverhead, long start, Map> responses)
  5. commit(Object tx)
  6. createFuture()
  7. exceptionallyCompletedFuture( final Throwable e)
  8. exceptionallyCompletedFuture(final Throwable t)
  9. getAll(List> futures)