ReentrantLock – should we check who holds the lock while unlocking in finally block?
Advertisements A simple snippet get stuck often when delay is slightly high: public String getToken(String userId, ReentrantLock lock) throws InterruptedException { try { // lock is in a cache of ConcurrentHashMap with key of userId if (!lock.tryLock(LOCK_TIMEOUT_SEC, TimeUnit.SECONDS)) { throw new AppException("Could not get lock in " + LOCK_TIMEOUT_SEC + "s"); // 10 sec }… Read More ReentrantLock – should we check who holds the lock while unlocking in finally block?