Stream 并行流执行了15万次左右电脑卡死,代码不再执行下去
for(int i=0;iif(i<(step-1)){
System.out.println("notStock正在执行第"+(i*rows)+"到"+((i+1)*rows)+"条记录写入至表格");
List attoItemsList = attoItemsServiceCom.AttoItems_notStock((i*rows),((i+1)*rows));
attoItemsList.parallelStream()
.forEach(z->{
z.setPurity(Purity(z.getSupplierProductID()));
z.setStockStatus("");
"数据库单条插入方法";
System.out.println(z);
});
}else {
System.out.println("notStock正在执行第"+(i*rows)+"到"+count+"条记录写入至表格");
List attoItemsList = attoItemsServiceCom.AttoItems_notStock((i*rows),count);
attoItemsList.parallelStream()
.forEach(z->{
z.setPurity(Purity(z.getSupplierProductID()));
z.setStockStatus("");
"数据库单条插入方法";
System.out.println(z);
});
}
没有报错,但是卡着不动了(控制台没有任何输出)
尝试在每个stream流forEach后,让暂停5秒后执行
能达到百万条数据库插入语句完全插入中途不死机,不出错