1.分段操作
public void doSomeThingSubsection(List<String> list,int length)throws SystemException{
if(CollectionUtils.isNotEmpty(list)){
int size = list.size();
if (size > length){
int num = size % length == 0 ? size / length : size / length + 1;
for (int i = 0; i < num; i++) {
int startIndex = i * length;
int endtIndex = (i + 1) * length;
endtIndex = endtIndex > size ? size : endtIndex;
//执行一段操作
doSomeThing(list.subList(startIndex, endtIndex));
}
}else{
//执行一段操作
doSomeThing(list);
}
}
}