// 批量修改
if (CollectionUtils.isNotEmpty(updateKsxxList)) {
int oneBatch = MagicNumber.ONE_HUNDRED;
int times = updateKsxxList.size() % oneBatch == MagicNumber.ZERO ? (updateKsxxList.size() / oneBatch)
: ((updateKsxxList.size() / oneBatch) + 1);
final CountDownLatch countDownLatch = new CountDownLatch(times);
for (int i = MagicNumber.ZERO; i < times; i++) {
List<Ksxx> updateList = new ArrayList<>();
if (i == (times - 1)) {
updateList = updateKsxxList.subList(i * oneBatch, updateKsxxList.size());
} else {
updateList = updateKsxxList.subList(i * oneBatch, (i + 1) * oneBatch);
}
List<Ksxx> finalUpdateList = updateList;
new Thread(new Runnable() {
public void run() {
ksxxMapper.updateBatchAll(finalUpdateList);
countDownLatch.countDown();
}
}).start();
}
try {
countDownLatch.await();
} catch (InterruptedException e) {
log.error(e.getMessage());
}
}
标签:updateKsxxList,oneBatch,updateList,CountDownLatch,new,size
From: https://www.cnblogs.com/heavenTang/p/16806391.html