CompletableFuture运行异步方法

时间:2018-08-14 19:32:48

标签: java multithreading completable-future

我找到了一些例子

Wrapping an asynchronous computation into a synchronous (blocking) computation

但是我如何将异步方法包装到CompletableFuture

类似的东西:

RxJava2Baz baz = Single.create(new SingleOnSubscribe<Baz>() {
                @Override
                public void subscribe(SingleEmitter<Baz> emitter) {
                    doSomethingAsync(fooArg, barArg, new BazComputationSink() {
                        @Override
                        public void onBazResult(Baz result) {
                            emitter.onSuccess(result);
                        }
                    });
                }
            }).toFuture().get();

0 个答案:

没有答案