标签: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