java8並行流操作
阿新 • • 發佈:2018-12-27
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())
;