mirror of
https://gitee.com/jd-platform-opensource/asyncTool.git
synced 2024-12-19 03:30:30 +08:00
让同步执行结果有个返回值
This commit is contained in:
parent
b7c36196f4
commit
73db76404c
@ -33,7 +33,7 @@ public class Async {
|
|||||||
CompletableFuture[] futures = new CompletableFuture[workerWrappers.size()];
|
CompletableFuture[] futures = new CompletableFuture[workerWrappers.size()];
|
||||||
for (int i = 0; i < workerWrappers.size(); i++) {
|
for (int i = 0; i < workerWrappers.size(); i++) {
|
||||||
WorkerWrapper wrapper = workerWrappers.get(i);
|
WorkerWrapper wrapper = workerWrappers.get(i);
|
||||||
futures[i] = CompletableFuture.runAsync(() -> wrapper.work(COMMON_POOL, timeout), COMMON_POOL);
|
futures[i] = CompletableFuture.runAsync(() -> wrapper.work(COMMON_POOL, timeout), pool);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
CompletableFuture.allOf(futures).get(timeout, TimeUnit.MILLISECONDS);
|
CompletableFuture.allOf(futures).get(timeout, TimeUnit.MILLISECONDS);
|
||||||
|
Loading…
Reference in New Issue
Block a user