mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
!473 waitAny函数提供返回值,用于在获取最先执行完成的任务中的返回值
Merge pull request !473 from 阿超/v5-dev
This commit is contained in:
commit
de403f9c20
@ -31,11 +31,12 @@ public class AsyncUtil {
|
|||||||
* 等待任意一个任务执行完毕,包裹了异常
|
* 等待任意一个任务执行完毕,包裹了异常
|
||||||
*
|
*
|
||||||
* @param tasks 并行任务
|
* @param tasks 并行任务
|
||||||
|
* @return 执行结束的任务返回值
|
||||||
* @throws UndeclaredThrowableException 未受检异常
|
* @throws UndeclaredThrowableException 未受检异常
|
||||||
*/
|
*/
|
||||||
public static void waitAny(CompletableFuture<?>... tasks) {
|
public static Object waitAny(CompletableFuture<?>... tasks) {
|
||||||
try {
|
try {
|
||||||
CompletableFuture.anyOf(tasks).get();
|
return CompletableFuture.anyOf(tasks).get();
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
throw new ThreadException(e);
|
throw new ThreadException(e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user