小编gur*_*gou的帖子

如果链中的第一个方法是异步的,那么一系列方法调用 (CompletableFuture API) 是否会异步执行?

我正在学习 CompletableFuture API,有一个例子:

CompletableFuture.completedFuture(url)
                 .thenComposeAsync(this::readPage, executor)
                 .thenApply(this::getImageURLs)
                 .thenApply(this::saveFoundImages)
                 .....
Run Code Online (Sandbox Code Playgroud)

我有一个问题:如果我将thenComposeAsync(...)方法作为第一个调用,链中的其他方法会在executor我通过参数传递的方法中执行,还是应该使用async调用其他方法以在特定执行程序中异步执行?

java concurrency multithreading asynchronous completable-future

3
推荐指数
1
解决办法
262
查看次数