java - CompletableFuture from Callable? -


today experimented "new" completablefuture java 8 , found myself confused when didn't find runasync(callable) method. can myself shown below, why (to me obvious , useful utility method) missing? i missing something?

public static <t> completablefuture<t> asfuture(callable<? extends t> callable, executor executor) {     completablefuture<t> future = new completablefuture<>();     executor.execute(() -> {         try {             future.complete(callable.call());         } catch (throwable t) {             future.completeexceptionally(t);         }     });     return future; }

you supposed use supplyasync(supplier<u>)

in general, lambdas , checked exceptions not work together, , completablefuture avoids checked exceptions design. though in case should no problem.

related threads:

http://cs.oswego.edu/pipermail/concurrency-interest/2012-december/010486.html

http://cs.oswego.edu/pipermail/concurrency-interest/2014-august/012911.html


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -