14°

JDK1.8集合进阶篇

常用的就有过滤以及循环,还有排序、分组等功能请自行百度

List<Bean> list = new ArrayList<>();
循环
list.forEach( bean-> {
       System.out.println(bean.getXXX);
    });
过滤
list = refunds.stream()
                .filter(bean-> bean.getXXX == 37)
                .collect(Collectors.toList());

HashMap<Integer, String> map = new HashMap<>(); map.forEach((k, v) -> System.out.println(k + "=" + v));

开启多线程进行处理

   ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10); //线程
    CountDownLatch countDownLatch = new CountDownLatch(10);
        fixedThreadPool.execute(() -> {
            try {
               //TODO
            } catch (Exception e) {
                e.getMessage();
            } finally {
                countDownLatch.countDown();
            }
        });
    countDownLatch.await();//等待所有子线程执行完
    fixedThreadPool.shutdown(); //结束线程池

本文由【BIG_BRA】发布于开源中国,原文链接:https://my.oschina.net/Pirvate/blog/3159740

全部评论: 0

    我有话说: