public void inspectionPurchaseRequisitionByBxId(Integer bxId){
List<Integer> idList = AutoInspectionPurchaseOrderHandle.getIds();
if (CollectionUtil.isNotEmpty(idList))
{
ThreadPoolTaskExecutor commonTaskSchedulingThreadPool = SpringUtil.getBean("commonTaskSchedulingThreadPool");
List<CompletableFuture<Integer>> futures = new ArrayList<>();
for (Integer id : idList)
{
futures.add(
CompletableFuture.supplyAsync(() -> {
log.info("线程{}执行方法",Thread.currentThread().getName());
return id;
}, commonTaskSchedulingThreadPool)
);
}
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
for (CompletableFuture<Integer> future : futures)
{
try {
Integer s = future.get();
log.info("返回值" + s);
}catch (InterruptedException | ExecutionException e)
{
e.printStackTrace();
}
}
}
}
copied