andy kumar wrote:What I am looking for is an example where if i have a hashmap/queue which is shared by more than 2 threads how it will cause an issue and if I replace it with concurrenthashmap/concurrentlinkedqueue, how does it fix it. I know this is a very basic question but any help would be appreciated.
There are countless things that two threads can do with a collection. And hence, there are countless things that could happen due to race conditions. Of these countless possible outcomes, some will be fine and not need synchronization, some will not be fine and will need thread safe collections like the concurrent hashmap, and some, will not be thread safe, even with the use of a concurrent hashmap.
How will examples help you understand it? Especially, since concurrent hashmaps may not work in every case?
Henry