以下是我的代码:
@Component
public PaymentClass ...
private BigDecimal addAllAmount(List<String> list) {//here is the list
List<ListenableFuture<Response>> responseFutures = new ArrayList<>();
for(String str:list){
responseFutures.add(payment.query(getQueryRequest(str)));//external soa service
}
List<BigDecimal> listOfAmount = new ArrayList<>();
for(ListenableFuture<Response> future : responseFutures){
Response response = (Response)future.get();
listOfAmount.add(response.getAmount());
}
return listOfAmount.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
}
....
}
方法'addAllAmount'想要总结支付金额,为了提高性能,我使用ListenableFuture使称为'payment.query'的外部SOA服务异步。我的问题是:我不分配任何其他线程池,将创建多少个线程?与“列表”的大小相同吗?