public interface BatchHandlerInterface<T> { /** * 分批回调方法 * */ public void handler(List<T> subList); }
--------------------------------------------------------
public abstract class BatchHandlerList<T> implements BatchHandlerInterface<T> { private static final Logger LOGGER = Logger.getLogger(BatchHandlerList.class); //每次处理条数 private Integer perNum; private List<T> aylist; public BatchHandlerList(Integer perNum, List<T> aylist) { super(); this.perNum = perNum; this.aylist = aylist; } /** * 分批调用方法 * */ public void handlerList(){ try{ if(aylist!=null && aylist.size() > 0){ int size = aylist.size(); int startIndex = 0; int endIndex = 1; int num = 1; if (size > perNum) { num = size / perNum; }