1. 程式人生 > >java8並行流操作

java8並行流操作

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())
                ;