public static final int BATCH_SIZE = 1000;
// 假设有一个List<Student> ,长度为2000条, 并填充好了数据
List<Student> studentList = new ArrayList<Student>(2000);
List<Student> pageList = null;
for (int from = 0, to = 0, size = studentList.size(); from < size; from = to) {
to = Math.min(from + BATCH_SIZE, size);
pageList = studentList.subList(from, to);
// 进行分批处理 pageList;
}
网友评论