首页 > 其他 > 详细

初始化list

时间:2020-07-29 22:03:52      阅读:57      评论:0      收藏:0      [点我收藏+]
    public static void main(String[] args) {
        CyclicBarrier cyclicBarrier = new CyclicBarrier(2, () -> {
            System.out.println("====");
        });
        List<Integer> list = IntStream.rangeClosed(1, 100).boxed().collect(Collectors.toList());
        List<List<Integer>> partition = Lists.partition(list, 50);
        ExecutorService executorService = Executors.newFixedThreadPool(4);
        for (List<Integer> list1 : partition) {
            executorService.submit(()->{
                try {
                    Thread.sleep(2000);
                    cyclicBarrier.await();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                } catch (BrokenBarrierException e) {
                    e.printStackTrace();
                }
            });
        }
    }

  

初始化list

原文:https://www.cnblogs.com/juncaoit/p/13399313.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!