我的控制器正在根据某些条件进行异步呼叫获取国家/地区列表。
CompletableFuture<List<Country>> countriesByLanguageFuture = countryClient.getCountriesByLanguage("fr");
CompletableFuture<List<Country>> countriesByRegionFuture = countryClient.getCountriesByRegion("europe");
现在我需要获取以下国家/地区列表。
List<country> ctryList1= countriesByLanguageFuture.get();
List<country> ctryList2= countriesByRegionFuture.get();
现在我的问题是因为get()
被阻止了,我真的必须做下面的事情来等待所有过程完成。
CompletableFuture.allOf(countriesByLanguageFuture, countriesByRegionFuture);
我想我在某个地方迷路了。