in reply to Avoid Locking Entire Hashes
I suggest that a simple mutex to control the entire hash structure is the only safe approach. If the hash table is a central “hot spot,” then perhaps what you really need to do is to reconsider the use of threads at all, or at the very least, to reconsider the roles of the various threads in the application.
The technical reason is that... a hash is one great-big data structure, and you need to protect the whole thing. The practical reason is that, if you have a one-lane road on a superhighway, only one car can possibly go through at one time and it would be better to set-aside one thread to do that job, and maybe to just have one thread. Traffic-jams consume a tremendous amount of purely wasted time.