What I want to do is to start out using some implementation of a Map
and accumulate data into it by iterating over a parallel collection. Keys can "overlap" between threads as the keys are probabilistically generated (related to random number generation).
Ex. Thread 1 wants to add key = A value = 1 to the map. If it already exists, add 1 to the existing value (since value is 1) - if not, create the mapping. Meanwhile, another thread has key = A and value = 2, and wants to do the same thing.
Is there a way to do this without creating an entire Actor
system?
ConcurrentHashMap
from Java's library seems to look interesting, but the "weakly consistent" iterators are bothering me regarding safety of upating the map across threads..