我有一个对象集合。我必须在这个返回 Future 的对象集合上调用一个方法。现在我使用get()
on Future 以使操作同步。如何将其转换为异步?
for (Summary summary : summaries) {
acmResponseFuture(summary.getClassification()));
String classification = summary.getClassification();
// this is a call which return Future and which is a sync call now
AcmResponse acmResponse = acmResponseFuture(classification).get();
if (acmResponse != null && acmResponse.getAcmInfo() != null) {
summary.setAcm(mapper.readValue(acmResponse.getAcmInfo().getAcm(), Object.class));
}
summary.setDataType(DATA_TYPE);
summary.setApplication(NAME);
summary.setId(summary.getEntityId());
summary.setApiRef(federatorConfig.getqApiRefUrl() + summary.getEntityId());
}