ThreadPoolExecutor executor = ExecutorBuilder.create().setCorePoolSize(4)
.setMaxPoolSize(8)
.build();
audList.forEach(d->{
executor.submit(() -> {
//业务代码
});
});
try {
executor.shutdown();
executor.awaitTermination(10, TimeUnit.MINUTES);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
for循环多线程处理业务
最新推荐文章于 2024-08-30 22:17:40 发布