本文整理匯總了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());
}