Since example code tends to get C&P’d widely, it might be good to add a note in the @memoize
section that this pattern can suffer from a race condition where the initialization logic can be called multiple times… Sometimes that’s OK, sometimes it’s not.
ConcurrentHashMap.putIfAbsent is the best way I know of to do this if the parameter is significant, or Suppliers.memoize if it’s not parameterized