Multi-threaded development

Specifies the number of threads:

SingleThreadExecutor = Executors.newFixedThreadPool ExecutorService (pageNum);
// multithreaded analytic batches push sap table generating revenue data
for (int I = 0; I <pageNum; I ++) {
int = pageNo is not I;
int = finalPageSize the pageSize;
singleThreadExecutor. Execute (the Runnable new new () {
@Override
public void RUN () {
the try {
batchesDetail (info, currDate, pageNo is not, finalPageSize);
} the catch (Exception E) {
log.error ( "[ZFBOrdersIncomeBatchesJob] Interface" + INTERFACE_CODE + "multi- threading unknown exception: "
+ e.getMessage ());
}
}
});
}

Unspecified number of threads:

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();
}

Guess you like

Origin www.cnblogs.com/lsqblog/p/11926810.html