Alexey_Skadorva

Untitled

Dec 20th, 2020
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.35 KB | None | 0 0
  1. class UserStats {
  2.  
  3.         private Map<String, AtomicLong> hitsPerUser = new ConcurrentHashMap<>()
  4.  
  5.         private void onUserCall(String userId) {
  6.             if (userId == null) {
  7.                 return;
  8.             }
  9.  
  10.             hitsPerUser.putIfAbsent(userId, new AtomicLong());
  11.             hitsPerUser.get(userId).addAndGet(1L);
  12.         }
  13.     }
Advertisement
Add Comment
Please, Sign In to add comment