Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. @SessionScoped
  2. public class ConversationLocks implements Serializable {
  3.  
  4. private final ConcurrentHashMap<String, Lock> conversationLocks = new ConcurrentHashMap<>();
  5.  
  6. public Lock get(String cid) {
  7. ReentrantLock newLock = new ReentrantLock();
  8. Lock alreadyAvailableLock = conversationLocks.putIfAbsent(cid, newLock);
  9. return alreadyAvailableLock == null ? newLock : alreadyAvailableLock;
  10. }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement