It can simplify using computeIfAbesnt.

Comment From: rstoyanchev

I revised this further to remove the surrounding synchronized block since computeIfAbsent on ConcurrentHashMap is already synchronized internally.