I have a HashMap in my program which is accessed by multiple threads, and is occasionally set by a single thread.
HashMap
For example:
Map
HashMap is not thread safe. You can use any of the followings
Check this similar answer here