本文整理汇总了Java中java.util.concurrent.CompletableFuture.thenRunAsync方法的典型用法代码示例。如果您正苦于以下问题:Java CompletableFuture.thenRunAsync方法的具体用法?Java CompletableFuture.thenRunAsync怎么用?Java CompletableFuture.thenRunAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.CompletableFuture
的用法示例。
在下文中一共展示了CompletableFuture.thenRunAsync方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ensureConstN
import java.util.concurrent.CompletableFuture; //导入方法依赖的package包/类
@Benchmark
public Void ensureConstN() throws InterruptedException, ExecutionException {
CompletableFuture<Void> f = constVoidFuture;
for (int i = 0; i < N.n; i++)
f = f.thenRunAsync(ensureF);
return f.get();
}
示例2: ensurePromise
import java.util.concurrent.CompletableFuture; //导入方法依赖的package包/类
@Benchmark
public Void ensurePromise() throws InterruptedException, ExecutionException {
CompletableFuture<Void> p = new CompletableFuture<Void>();
CompletableFuture<Void> f = p.thenRunAsync(ensureF);
p.complete(null);
return f.get();
}
示例3: ensurePromiseN
import java.util.concurrent.CompletableFuture; //导入方法依赖的package包/类
@Benchmark
public Void ensurePromiseN() throws InterruptedException, ExecutionException {
CompletableFuture<Void> p = new CompletableFuture<>();
CompletableFuture<Void> f = p;
for (int i = 0; i < N.n; i++)
f = f.thenRunAsync(ensureF);
p.complete(null);
return f.get();
}
示例4:
import java.util.concurrent.CompletableFuture; //导入方法依赖的package包/类
public <T> CompletableFuture<Void> thenRun
(CompletableFuture<T> f, Runnable a) {
return f.thenRunAsync(a);
}
示例5: ThreadExecutor
import java.util.concurrent.CompletableFuture; //导入方法依赖的package包/类
public <T> CompletableFuture<Void> thenRun
(CompletableFuture<T> f, Runnable a) {
return f.thenRunAsync(a, new ThreadExecutor());
}