SHARE
TWEET

Untitled

a guest Jun 16th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Sln {
  2.  
  3.     AtomicInteger globalCounter = new AtomicInterger();
  4.     Map<String, Integer> counterPerKey = new ConcurrentHashMap<>()
  5.  
  6. class Holder{
  7.     Integer value
  8. }
  9.  
  10.     public Holder doWorkMultipleThreads(String key) {
  11.          if (total.get() < 1000) {
  12.  
  13.           Integer newTotal = counterPerKey.merge(key, 1, Integer::sum);
  14.           globalCounter.increment();
  15.          return new Holder(newTotal);
  16.  
  17.     }
  18.  
  19. }
  20.  
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top