线程池分页读取100万级数据

        //每次查一千条
        int size = 1000;
        //读取
        Integer count = yyAmazonInventoryReportMapper.findAllCount();
        //查几次
        int thread = count / size + 1;
        for (int i = 0; i < thread; i++) {
            int finalI = i;
            threadPoolConfig.asyncServiceExecutor().execute(() -> {
                int PAGE_INDEX = finalI * size;
                int PAGE_SIZE = size;
                DataMigrationQuery query = new DataMigrationQuery();
                query.setPage(PAGE_INDEX);
                query.setLimit(PAGE_SIZE);
                List<YyAmazonInventoryReport> reports = yyAmazonInventoryReportMapper.findAll(query);
                this.ClearTableReport(reports);
            });
        }
原文地址:https://www.cnblogs.com/zrboke/p/15097632.html