Use ConcurrentHashMap Instead. Because there is no iterator , it is useless to use synchronized block.