列表分片,及并行执行样例
Set<String> ips = Stream.of("1","2","3","4","5","6","7","8","9","10")
// 按照2个为一组,进行切片操作
List<List<String>> partition = Lists.partition(Lists.newArrayList(ips), 2);
// 切片后,并行执行
IntStream.range(0, partition.size()).parallel().forEach(index -> {
List<String> subIps = partition.get(index);
// 每2个为一组数据,进行计算
});