【发布时间】:2021-03-24 17:51:41
【问题描述】:
我有一个for循环来根据for循环的增量发起请求。
List<String> listModel = new ArrayList<>();
for(int i=0;i<5;i++)
{
String resp = initiateRequest(i);
listModel.add(resp);
}
public String initiateRequest(int i)
{
String url = String.format("http://api.github.com/"+i);
String response = restTemplate.getForObject(url);
return response;
}
想要将其转换为 CompletableFuture Async。
【问题讨论】:
标签: spring-boot for-loop asynchronous completable-future