demand
when querying the list of data in paging, I want to query the total number of items at the same time, but I think the following code is a little tedious, is there any easier way, or is there any third-party framework that can simplify logic like this
ExecutorService executorService = Executors.newFixedThreadPool(2);
CountDownLatch countDownLatch = new CountDownLatch(2);
Map<String, Object> map = new HashMap<>();
//
executorService.submit(() -> {
List<Integer> data = Lists.newArrayList(1, 2, 3);
map.put("data", data);
countDownLatch.countDown();
});
//
executorService.submit(() -> {
int count = 10;
map.put("count", count);
countDownLatch.countDown();
});
countDownLatch.await();
System.out.println(map);