Don’t blindly replace ConcurrentHashMap with Hashmap for implementing concurrency in java collection maps, as this will still have the underlying concurrency problem if the get,check,act pattern is followed.
- Therefore, follow to replace first HashMap with ConcurrencyHashMap.
- Replace get,check,act with more built-in atomic methods such as “computeIfPresent” etc., wherein the atomicity is guaranteed and thread safety of the unit of work across several threads will be synchronized without loss of the adding synchronized keyword which will revert the performance of the Concurrency collections.