private ReentrantLock lookupLockForAcquire(CacheKey cacheKey) {
        CacheKey mutex = interner.intern(cacheKey); // Ensure that the mutex used in the next line is the same for objects that are equal.
        synchronized(mutex) {
            LockAndCount lac = locks.get(mutex);
            if (lac == null) {
                lac = new LockAndCount(new ReentrantLock());
                lac.count = 1;
                locks.put(mutex, lac);
            }
            else {
                lac.count++;
            }

            return lac.lock;
        }
    }
Keep track of the locks that are currently being used.
xmppserver/src/main/java/org/jivesoftware/util/cache/lock/LocalLock.java