parallelStream

List<PaymentRecord> recordExts = statementBos.parallelStream()
        .map(bo -> {
            Long rsid = bo.getRsid();
            PaymentRecord paymentRecord= new PaymentRecord();
            ext.setRsid(rsid);
            ext.setShouldAmount(plan.get(rsid));
            ext.setOrderNo(orderNo);
            ext.setInvestorCode(investorCode);
            ext.setInvestorId(Long.valueOf(statementBo.getInvestorId()));
            return paymentRecord;
        }).collect(Collectors.toList());
List<UserInfo> userInfoList = DaoContainers.getUserInfoDAO().queryAllByList(new UserInfoModel());   
userInfoList.parallelStream().forEach(RedisUserApi::setUserIdUserInfo);
parallelStream其实就是一个并行执行的流,它通过默认的ForkJoinPool,可能提高你的多线程任务的速度.

版权声明:本文为weixin_37556006原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。