java8并行流操作

来源:互联网 发布:微星 网络唤醒 编辑:程序博客网 时间:2024/06/08 17:39

1、多参数情况

 BiConsumer<AliGameMapping, CallerSyncRule> cc = (gameApp, r) -> {                WdjData data = WdjDataService.getEntityInfo(gameApp,r);                if(data!=null){                    list.add(data);                }            }; gameMapList.parallelStream()            .forEach(a->            cc.accept(a, rule)                    )            ;


2、单个参数情况

list = gameMapList.parallelStream()                .filter(app -> app!=null)                .peek(app -> app.setRule(rule))                .map(WdjDataService::getEntityInfo)                .collect(Collectors.toList())                ;


0 0