Java tutorial
//package com.java2s; //License from project: Apache License import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Semaphore; public class Main { private static ConcurrentHashMap<String, Semaphore> semaphoreMap = new ConcurrentHashMap<>(); /** * Releases the locked semaphore for the given key. * * @param key key for getting the locked semaphore out of the hashmap. */ public static void releaseChat(String key) { Semaphore semaphore = semaphoreMap.get(key); if (semaphore != null) { semaphore.release(); } } }