bug PercentageOfParallelExecutor 中任务收集列表指定初始值,避免不必要的扩容;复原其他测试案例

This commit is contained in:
luoyi
2025-07-15 13:37:18 +08:00
parent c5052b1ef3
commit d342a08af5

View File

@@ -29,7 +29,7 @@ public class PercentageOfParallelExecutor extends ParallelStrategyExecutor {
int thresholdCount = (int) Math.ceil(total * whenCondition.getPercentage());
// 已完成任务收集器(对 List 加锁保证线程安全)
List<CompletableFuture<WhenFutureObj>> completedFutures = Collections.synchronizedList(new ArrayList<>(thresholdCount));
List<CompletableFuture<WhenFutureObj>> completedFutures = Collections.synchronizedList(new ArrayList<>(Math.max(thresholdCount, 1) << 1));
// 阈值触发门闩
CompletableFuture<Void> thresholdFuture = new CompletableFuture<>();