Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SessionScoped
- public class ConversationLocks implements Serializable {
- private final ConcurrentHashMap<String, Lock> conversationLocks = new ConcurrentHashMap<>();
- public Lock get(String cid) {
- ReentrantLock newLock = new ReentrantLock();
- Lock alreadyAvailableLock = conversationLocks.putIfAbsent(cid, newLock);
- return alreadyAvailableLock == null ? newLock : alreadyAvailableLock;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement