long start = System.currentTimeMillis();
int threadNum = 50;
ExecutorService exec = Executors.newFixedThreadPool(threadNum);
List<Callable<Integer>> tasks = new ArrayList<Callable<Integer>>();
Callable<Integer> task = null;
List<List<Map<String, Object>>> cutList = ObjectUtils.averageAssign(list, 100);
for (List<Map<String, Object>> idMap : cutList) {
task = new Callable<Integer>() {
@Override
public Integer call() throws Exception {
return 1;
}
};
tasks.add(task);
}
exec.invokeAll(tasks);
exec.shutdown();
System.out.println("线程任务执行结束");
System.err.println("执行任务消耗了 :" + (System.currentTimeMillis() - start) + "毫秒");