起因 : 由于客户反馈说通过系统上传了200条数据 , 点击上传 , 然后半天没有反应(30分钟左右) ;
原因 : 在做数据对比的时候 , 采用的双重For的方式 , 结果数据量非常大 , 外层循环是数据库中所有的用户数据(10_0000+) , 内层是200 , 按理说是不会出问题的 , 以前做过10000*10000左右的For循环也没有执行这么长时间 , 经过排查 , 问题出在了打印日志上…
**测试 : **
**测试代码 : **
import java.util.ArrayList;
import java.util.List;
public class DateTest {
public static void main(String[] args) {
List<String> strList = new ArrayList<>();
long startTime = System.currentTimeMillis();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
for (int i = 0; i < 1000; i++) {
for (int j = 0; j < 10000; j++) {
strList.add("" + i +"--"+ j); // ①
System.out.println("程序执行--" + i + "--" + j); // ②
System.out.println