码迷,mamicode.com
首页 > 编程语言 > 详细

多线程研发

时间:2019-11-25 13:37:17      阅读:52      评论:0      收藏:0      [点我收藏+]

标签:art   catch   cut   code   shu   task   rsa   com   inter   

指定线程个数:

ExecutorService singleThreadExecutor = Executors.newFixedThreadPool(pageNum);
//多线程分批次解析收入表生成推送sap数据
for (int i = 0; i < pageNum; i++) {
int pageNo = i;
int finalPageSize = pageSize;
singleThreadExecutor.execute(new Runnable() {
@Override
public void run() {
try {
batchesDetail(info, currDate, pageNo, finalPageSize);
} catch (Exception e) {
log.error("[ZFBOrdersIncomeBatchesJob]接口" + INTERFACE_CODE + "多线程处理出现未知异常:"
+ e.getMessage());
}
}
});
}

未指定线程个数:

while (yPageNo >= 0) {
ForkJoinPool pool = ForkJoinPool.commonPool();
List<ZfbOrdersIncomeDetails> ybDetailslist = zfbOrdersAccountingReadDao.
getIncomeDataByDsType(startTime, DispathType.YANBAO.getCode(),
yPageNo--,pageSize);
ZFBOrderDispathJob.ybCallableThread task = new ZFBOrderDispathJob.
ybCallableThread(0, ybDetailslist.size(), ybDetailslist);
pool.submit(task);
pool.awaitTermination(1, TimeUnit.MINUTES);
pool.shutdown();
}

多线程研发

标签:art   catch   cut   code   shu   task   rsa   com   inter   

原文地址:https://www.cnblogs.com/lsqblog/p/11926810.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!