I am writing a program that makes extensive use of large HashMaps. It is multithreaded, so I used read and write locks when accessing it. However, it has a special property that I would like to use.
After the data is "placed" in the HashMap, this data never changes. Ever. Whenever there is a change in the state of this data structure, in fact, it simply creates a new βgenerationβ of the structure, leaving the old whole.
That is, is it safe to read the value from the HashMap at the same time that the other thread is writing the value, knowing that the other thread will never write the value you are reading? Is there any simple hash table that will give me such a guarantee?
source share