public interface CompletionStage<T>
stage.thenApply(x -> square(x)).thenAccept(x -> System.out.print(x)).thenRun(() -> System.out.println())
。一个附加的形式(撰写)应用阶段本身的功能,而不是他们的结果。Executor
)。默认情况下,异步方式执行的性质是由completionstage实现指定接口,不。显式执行器参数的方法可以有任意的执行性能,甚至可能不支持并行执行,但所处理的一种方式,可不同步。whenComplete
允许行动注入不顾结果,否则保存结果的完成。方法handle
可以让舞台上的一个置换效果,可以使其他依赖阶段进一步处理计算。在所有其他情况下,如果一个阶段的计算突然终止与(没有)异常或错误,并要求其完成所有依赖阶段完成的非常好,有CompletionException
持有异常的原因。如果一个阶段依赖于两个阶段,和完整的异常,然后completionexception可能对应于这些例外之一。如果一个阶段依赖于两个其他人,只有一个完成了异常,没有保证的依赖阶段是否完成正常或异常。在whenComplete
方法的情况下,当提供的行动本身遇到异常,然后异常完成阶段这个例外如果不是已经完成的异常。所有的方法都坚持上述触发,执行和特殊的完成规范(这是不重复在个别的方法规格)。此外,在过去的一个完成的结果参数(即为类型参数的方法T
)接受他们可能是无效的,任何其他参数传递null值将导致NullPointerException
抛出。
此接口不定义最初创建的方法,强制完成正常或异常,探测完成状态或结果,或等待一个阶段完成。实现completionstage可以提供达到这些效果的方法,适当的。方法toCompletableFuture()
通过提供一个公共的转换类型使这个接口的不同实现之间的互操作性。
Modifier and Type | Method and Description |
---|---|
CompletionStage<Void> |
acceptEither(CompletionStage<? extends T> other, Consumer<? super T> action)
返回一个新的completionstage,当这种或其他特定阶段的正常完成,执行相应的结果作为参数提供的行动。
|
CompletionStage<Void> |
acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action)
返回一个新的completionstage,当这种或其他特定阶段的正常完成,利用这个阶段的默认的异步执行机构执行,与相应的结果作为参数提供的行动。
|
CompletionStage<Void> |
acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor)
返回一个新的completionstage,当这种或其他特定阶段的正常完成,使用提供的遗嘱执行人执行,与相应的结果作为参数提供的功能。
|
<U> CompletionStage<U> |
applyToEither(CompletionStage<? extends T> other, Function<? super T,U> fn)
返回一个新的completionstage,当这种或其他特定阶段的正常完成,执行相应的结果作为参数提供的功能。
|
<U> CompletionStage<U> |
applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T,U> fn)
返回一个新的completionstage,当这种或其他特定阶段的正常完成,利用这个阶段的默认的异步执行机构执行,与相应的结果作为参数提供的功能。
|
<U> CompletionStage<U> |
applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T,U> fn, Executor executor)
返回一个新的completionstage,当这种或其他特定阶段的正常完成,使用提供的遗嘱执行人执行,与相应的结果作为参数提供的功能。
|
CompletionStage<T> |
exceptionally(Function<Throwable,? extends T> fn)
返回一个新的completionstage,当此阶段完成异常,执行这一阶段的异常作为参数提供的功能。
|
<U> CompletionStage<U> |
handle(BiFunction<? super T,Throwable,? extends U> fn)
返回一个新的completionstage,当此阶段完成正常或异常,进行这一阶段的结果和异常作为提供的函数参数。
|
<U> CompletionStage<U> |
handleAsync(BiFunction<? super T,Throwable,? extends U> fn)
返回一个新的completionstage,当此阶段完成正常或异常,利用这个阶段的默认的异步执行机构执行,这个阶段的结果和异常作为提供的函数参数。
|
<U> CompletionStage<U> |
handleAsync(BiFunction<? super T,Throwable,? extends U> fn, Executor executor)
返回一个新的completionstage,当此阶段完成正常或异常,是使用提供的遗嘱执行人执行,这个阶段的结果和异常作为提供的函数参数。
|
CompletionStage<Void> |
runAfterBoth(CompletionStage<?> other, Runnable action)
返回一个新的completionstage,当和其他阶段都正常完成,执行特定动作。
|
CompletionStage<Void> |
runAfterBothAsync(CompletionStage<?> other, Runnable action)
返回一个新的completionstage,当这种和其他特定阶段的正常完成,利用这个阶段的默认的异步执行机构执行特定动作。
|
CompletionStage<Void> |
runAfterBothAsync(CompletionStage<?> other, Runnable action, Executor executor)
返回一个新的completionstage,当这种和其他特定阶段的正常完成,执行给定的操作使用提供的遗嘱执行人看到规则覆盖出色的完成
CompletionStage 文档。
|
CompletionStage<Void> |
runAfterEither(CompletionStage<?> other, Runnable action)
返回一个新的completionstage,当这种或其他特定阶段的正常完成,执行特定动作。
|
CompletionStage<Void> |
runAfterEitherAsync(CompletionStage<?> other, Runnable action)
返回一个新的completionstage,当这种或其他特定阶段的正常完成,利用这个阶段的默认的异步执行机构执行特定动作。
|
CompletionStage<Void> |
runAfterEitherAsync(CompletionStage<?> other, Runnable action, Executor executor)
返回一个新的completionstage,当这种或其他特定阶段的正常完成,执行给定的操作使用提供的遗嘱执行人。
|
CompletionStage<Void> |
thenAccept(Consumer<? super T> action)
返回一个新的completionstage,当此阶段完成正常的情况下,执行这一阶段的结果作为参数提供的行动。
|
CompletionStage<Void> |
thenAcceptAsync(Consumer<? super T> action)
返回一个新的completionstage,当此阶段完成这个阶段通常使用默认的异步执行机构执行,这一阶段的结果作为参数提供的行动。
|
CompletionStage<Void> |
thenAcceptAsync(Consumer<? super T> action, Executor executor)
返回一个新的completionstage,当此阶段完成通常是使用提供的遗嘱执行人执行,这个阶段的结果作为参数提供的行动。
|
<U> CompletionStage<Void> |
thenAcceptBoth(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action)
返回一个新的completionstage,当和其他阶段都完全正常,是执行了两结果提供的操作参数。
|
<U> CompletionStage<Void> |
thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action)
返回一个新的completionstage,当这种和其他特定阶段的正常完成,利用这个阶段的默认的异步执行机构执行,与两结果提供的操作参数。
|
<U> CompletionStage<Void> |
thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action, Executor executor)
返回一个新的completionstage,当这种和其他特定阶段的正常完成,使用提供的遗嘱执行人执行,与两结果提供的函数参数。
|
<U> CompletionStage<U> |
thenApply(Function<? super T,? extends U> fn)
返回一个新的completionstage,当此阶段完成正常的情况下,执行这一阶段的结果作为参数提供的功能。
|
<U> CompletionStage<U> |
thenApplyAsync(Function<? super T,? extends U> fn)
返回一个新的completionstage,当此阶段完成这个阶段通常使用默认的异步执行机构执行,这一阶段的结果作为参数提供的功能。
|
<U> CompletionStage<U> |
thenApplyAsync(Function<? super T,? extends U> fn, Executor executor)
返回一个新的completionstage,当此阶段完成通常是使用提供的遗嘱执行人执行,这个阶段的结果作为参数提供的功能。
|
<U,V> CompletionStage<V> |
thenCombine(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn)
返回一个新的completionstage,当和其他阶段都完全正常,是执行了两结果提供的函数参数。
|
<U,V> CompletionStage<V> |
thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn)
返回一个新的completionstage,当这种和其他特定阶段的正常完成,利用这个阶段的默认的异步执行机构执行,与两结果提供的函数参数。
|
<U,V> CompletionStage<V> |
thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn, Executor executor)
返回一个新的completionstage,当这种和其他特定阶段的正常完成,使用提供的遗嘱执行人执行,与两结果提供的函数参数。
|
<U> CompletionStage<U> |
thenCompose(Function<? super T,? extends CompletionStage<U>> fn)
返回一个新的completionstage,当此阶段完成正常的情况下,执行这一阶段作为参数提供的功能。
|
<U> CompletionStage<U> |
thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn)
返回一个新的completionstage,当此阶段完成这个阶段通常使用默认的异步执行机构执行,这个阶段作为参数提供的功能。
|
<U> CompletionStage<U> |
thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn, Executor executor)
返回一个新的completionstage,当此阶段完成通常是使用提供的遗嘱执行人执行,这个阶段的结果作为参数提供的功能。
|
CompletionStage<Void> |
thenRun(Runnable action)
返回一个新的completionstage,当此阶段完成通常执行特定动作。
|
CompletionStage<Void> |
thenRunAsync(Runnable action)
返回一个新的completionstage,当此阶段完成这个阶段通常使用默认的异步执行机构执行特定动作。
|
CompletionStage<Void> |
thenRunAsync(Runnable action, Executor executor)
返回一个新的completionstage,当此阶段完成正常的情况下,使用提供的遗嘱执行人执行特定动作。
|
CompletableFuture<T> |
toCompletableFuture()
返回一个
CompletableFuture 保持相同特性,这一阶段完成。
|
CompletionStage<T> |
whenComplete(BiConsumer<? super T,? super Throwable> action)
返回相同的结果或例外,这一阶段的新completionstage,这个阶段完成时,执行特定动作的结果(或
null 如果没有)和异常(或
null 如果没有)这个阶段。
|
CompletionStage<T> |
whenCompleteAsync(BiConsumer<? super T,? super Throwable> action)
返回相同的结果或例外,这一阶段的新completionstage,这个阶段完成时,执行特定动作执行给定的操作这一阶段的默认的异步执行设施,其结果(或
null 如果没有)和异常(或
null 如果没有)这个阶段作为参数。
|
CompletionStage<T> |
whenCompleteAsync(BiConsumer<? super T,? super Throwable> action, Executor executor)
返回相同的结果或例外,这一阶段的新completionstage,这个阶段完成时,执行使用所提供的遗嘱执行人,给出的行动与结果(或
null 如果没有)和异常(或
null 如果没有)这个阶段作为参数。
|
<U> CompletionStage<U> thenApply(Function<? super T,? extends U> fn)
CompletionStage
文档。
U
-函数的返回类型
fn
-函数用于计算返回的值completionstage
<U> CompletionStage<U> thenApplyAsync(Function<? super T,? extends U> fn)
CompletionStage
文档。
U
-函数的返回类型
fn
-函数用于计算返回的值completionstage
<U> CompletionStage<U> thenApplyAsync(Function<? super T,? extends U> fn, Executor executor)
CompletionStage
文档。
U
-函数的返回类型
fn
-函数用于计算返回的值completionstage
executor
-执行器用于异步执行
CompletionStage<Void> thenAccept(Consumer<? super T> action)
CompletionStage
文档。
action
-完成返回completionstage之前执行的动作
CompletionStage<Void> thenAcceptAsync(Consumer<? super T> action)
CompletionStage
文档。
action
-完成返回completionstage之前执行的动作
CompletionStage<Void> thenAcceptAsync(Consumer<? super T> action, Executor executor)
CompletionStage
文档。
action
-完成返回completionstage之前执行的动作
executor
-执行器用于异步执行
CompletionStage<Void> thenRun(Runnable action)
CompletionStage
文档。
action
-完成返回completionstage之前执行的动作
CompletionStage<Void> thenRunAsync(Runnable action)
CompletionStage
文档。
action
-完成返回completionstage之前执行的动作
CompletionStage<Void> thenRunAsync(Runnable action, Executor executor)
CompletionStage
文档。
action
-完成返回completionstage之前执行的动作
executor
-执行器用于异步执行
<U,V> CompletionStage<V> thenCombine(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn)
CompletionStage
文档。
U
-其他completionstage的类型的结果
V
-函数的返回类型
other
-其他completionstage
fn
-函数用于计算返回的值completionstage
<U,V> CompletionStage<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn)
CompletionStage
文档。
U
-其他completionstage的类型的结果
V
-函数的返回类型
other
-其他completionstage
fn
-函数用于计算返回的值completionstage
<U,V> CompletionStage<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn, Executor executor)
CompletionStage
文档。
U
-其他completionstage的类型的结果
V
-函数的返回类型
other
-其他completionstage
fn
-函数用于计算返回的值completionstage
executor
-执行器用于异步执行
<U> CompletionStage<Void> thenAcceptBoth(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action)
CompletionStage
文档。
U
-其他completionstage的类型的结果
other
-其他completionstage
action
-完成返回completionstage之前执行的动作
<U> CompletionStage<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action)
U
-其他completionstage的类型的结果
other
-其他completionstage
action
-完成返回completionstage之前执行的动作
<U> CompletionStage<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action, Executor executor)
U
-其他completionstage的类型的结果
other
-其他completionstage
action
-完成返回completionstage之前执行的动作
executor
-执行器用于异步执行
CompletionStage<Void> runAfterBoth(CompletionStage<?> other, Runnable action)
CompletionStage
文档。
other
-其他completionstage
action
-完成返回completionstage之前执行的动作
CompletionStage<Void> runAfterBothAsync(CompletionStage<?> other, Runnable action)
CompletionStage
文档。
other
-其他completionstage
action
-完成返回completionstage之前执行的动作
CompletionStage<Void> runAfterBothAsync(CompletionStage<?> other, Runnable action, Executor executor)
CompletionStage
文档。
other
-其他completionstage
action
-完成返回completionstage之前执行的动作
executor
-执行器用于异步执行
<U> CompletionStage<U> applyToEither(CompletionStage<? extends T> other, Function<? super T,U> fn)
CompletionStage
文档。
U
-函数的返回类型
other
-其他completionstage
fn
-函数用于计算返回的值completionstage
<U> CompletionStage<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T,U> fn)
CompletionStage
文档。
U
-函数的返回类型
other
-其他completionstage
fn
-函数用于计算返回的值completionstage
<U> CompletionStage<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T,U> fn, Executor executor)
CompletionStage
文档。
U
-函数的返回类型
other
-其他completionstage
fn
-函数用于计算返回的值completionstage
executor
-执行器用于异步执行
CompletionStage<Void> acceptEither(CompletionStage<? extends T> other, Consumer<? super T> action)
CompletionStage
文档。
other
-其他completionstage
action
-完成返回completionstage之前执行的动作
CompletionStage<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action)
CompletionStage
文档。
other
-其他completionstage
action
-完成返回completionstage之前执行的动作
CompletionStage<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor)
CompletionStage
文档。
other
-其他completionstage
action
-完成返回completionstage之前执行的动作
executor
-执行器用于异步执行
CompletionStage<Void> runAfterEither(CompletionStage<?> other, Runnable action)
CompletionStage
文档。
other
-其他completionstage
action
-完成返回completionstage之前执行的动作
CompletionStage<Void> runAfterEitherAsync(CompletionStage<?> other, Runnable action)
CompletionStage
文档。
other
-其他completionstage
action
-完成返回completionstage之前执行的动作
CompletionStage<Void> runAfterEitherAsync(CompletionStage<?> other, Runnable action, Executor executor)
CompletionStage
文档。
other
-其他completionstage
action
-完成返回completionstage之前执行的动作
executor
-执行器用于异步执行
<U> CompletionStage<U> thenCompose(Function<? super T,? extends CompletionStage<U>> fn)
CompletionStage
文档。
U
-返回的结果completionstage类型
fn
-函数返回一个新的completionstage
<U> CompletionStage<U> thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn)
CompletionStage
文档。
U
-返回的结果completionstage类型
fn
-函数返回一个新的completionstage
<U> CompletionStage<U> thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn, Executor executor)
CompletionStage
文档。
U
-返回的结果completionstage类型
fn
-函数返回一个新的completionstage
executor
-执行器用于异步执行
CompletionStage<T> exceptionally(Function<Throwable,? extends T> fn)
fn
-函数用于计算返回的completionstage价值如果completionstage完成的异常
CompletionStage<T> whenComplete(BiConsumer<? super T,? super Throwable> action)
null
如果没有)和异常(或
null
如果没有)这个阶段。
action
-执行的动作
CompletionStage<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> action)
null
如果没有)和异常(或
null
如果没有)这个阶段作为参数。
action
-执行的动作
CompletionStage<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> action, Executor executor)
null
如果没有)和异常(或
null
如果没有)这个阶段作为参数。
action
-执行的动作
executor
-执行器用于异步执行
<U> CompletionStage<U> handle(BiFunction<? super T,Throwable,? extends U> fn)
null
如果没有)和异常(或
null
如果没有)本阶段完成时作为参数。
U
-函数的返回类型
fn
-函数用于计算返回的值completionstage
<U> CompletionStage<U> handleAsync(BiFunction<? super T,Throwable,? extends U> fn)
null
如果没有)和异常(或
null
如果没有)本阶段完成时作为参数。
U
-函数的返回类型
fn
-函数用于计算返回的值completionstage
<U> CompletionStage<U> handleAsync(BiFunction<? super T,Throwable,? extends U> fn, Executor executor)
null
如果没有)和异常(或
null
如果没有)本阶段完成时作为参数。
U
-函数的返回类型
fn
-函数用于计算返回的值completionstage
executor
-执行器用于异步执行
CompletableFuture<T> toCompletableFuture()
CompletableFuture
保持相同特性,这一阶段完成。如果这个阶段已经是一个completablefuture,此方法可能会返回这个阶段本身。否则,该方法调用可能会相当的效果
thenApply(x -> x)
,但返回类型
CompletableFuture
实例。一completionstage实施不选择与别人扔
UnsupportedOperationException
。
UnsupportedOperationException
如果实施不与completablefuture
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.