Java 循环遍历列表并每隔 10 次迭代休眠 1 秒
for (int i = 0; i < instLists.size(); i++) { // 处理每个 InstList InstList instList = instLists.get(i);
// 每 10 次迭代休眠 1 秒
if ((i + 1) % 10 == 0) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
原文地址: http://www.cveoy.top/t/topic/begi 著作权归作者所有。请勿转载和采集!