09: What is wrong with this code? HashMap & Race condition

Q. What is wrong with the following code snippet?

A. It is NOT thread-safe as a “HashMap” is not thread-safe as per the Java API, and race conditions can leave the “map” in “inconsistent state”. It is very hard…


Java Interview FAQs

800+ Java Interview Q&As

Top