list.parallelStream().forEach
side-effects
, Stream.
, , , , " " ( ), , forEach
, , . , , HashMap
, ... , , HashMap
? , , , , / ..
, ConcurrentHashMap
, -, - , .
- collect
Map
forEach
:
Map<Integer, TreeNode> map = list.parallelStream()
.collect(Collectors.toMap(
NodeData::getId,
TreeNode::new
));
, . , ( ), .