Why should I use concurrent characteristic in parallel stream with collect?

前端 未结 3 639
误落风尘
误落风尘 2020-11-27 19:52

Why should I use concurrent characteristic in parallel stream with collect:

List list =
        Collections.synchronizedList(new ArrayList<         


        
3条回答
  •  生来不讨喜
    2020-11-27 20:37

    Because of this : "Memory consistency effects: As with other concurrent collections, actions in a thread prior to placing an object into a ConcurrentMap as a key or value happen-before actions subsequent to the access or removal of that object from the ConcurrentMap in another thread."

提交回复
热议问题