After these posts Locking value objects of a ConcurrentHashMap
ConcurrentHashMap: how to replace the value of an entry only if the current value is smalle
Can we use Synchronized for each entry instead of ConcurrentHashMap?
And spending so much time, I think I should give up on concurrency (at least for now) and forget entry locking. It is too error-prone. Several times I came up with a solution, but again I found a bug.
So, if I want to scarify concurrency, and jut have a correct program, I think the easiest what is locking the whole hash table. So what is the best way to do that. I have 6 hash tables. One solution is using 6 HashMaps and whenever I want to do something use synchronized block. Is it OK, or I need to use ConcurrenHashMap? Note that I am using synchronized block.