マルチスレッド同時クエリーmysqlデータベースのデータ
2036 ワード
10 2 1 10 。 , , cpu, 。 java , java , , , , java , 。
List>> allStationsTimesAmount =
inputParamArrayList.stream()
.map(inputParam -> CompletableFuture.supplyAsync(() ->nonOilSalesAndPerCustomerTransactionDao.getTimesHoursInterval(inputParam), executorService))
.collect(Collectors.toList());
List> timesAmount = allStationsTimesAmount.stream()
.map(CompletableFuture::join)
.collect(Collectors.toList());
private List getBarcodeList(String[] deptIds, String[] ids) {
List list = new ArrayList<>();
List list1 = new ArrayList<>();
if (deptIds != null){
list = Arrays.asList(deptIds);
List>> allBarcodes =
list.stream()
.map(inputParam -> CompletableFuture.supplyAsync(() ->nonOilSalesAndPerCustomerTransactionDao.getBarcodesBydeptid(inputParam), executorService))
.collect(Collectors.toList());
List> listList = allBarcodes.stream()
.map(CompletableFuture::join)
.collect(Collectors.toList());
//List> List , flatMap
list1 =
listList.stream()
.flatMap(inner -> inner.stream()).collect(Collectors.toList());
}
if (ids != null){
list1.addAll(Arrays.asList(ids));
}
return list1;
}
転載先:https://www.cnblogs.com/herosoft/p/9909099.html