Three ways to make HashMap thread-safe
- Use: Hashtable which is thread-safe;
- Use: Hashmap objHashmap = Collections.synchronizedMap(new HashMap(….));
- Use: Block Synchronization mechanism. Where ever you are using the HashMap put those codes into block and sysnchronise that block with respect to HashMap object that you are having.


Leave a Reply