简单记录下,后面有时间 详细研究,
// 开启并行计算
Listcollect = dataList.getInnerOrganizations().stream()
.map(innerOrg -> createTaskSupplier(context, innerOrg))
.collect(Collectors.toList())
.stream()
.map(CompletableFuture::join)
.collect(Collectors.toList());logger.info("并行计算数量:{}", collect.size());
private CompletableFuturecreateTaskSupplier(OpenCategoryListContext context, Organization organization) { return CompletableFuture.runAsync( () -> do(context), "自定义线程池"); } // 构建线程池 int processors = Runtime.getRuntime().availableProcessors(); final ForkJoinPool forkJoinPool = new ForkJoinPool(processors);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)