private synchronized void close() throws IllegalMonitorStateException {
        lock.unlock();
        // Clear the reference to the key so the GC can remove the entry from the WeakHashMap if no-one else has it
        if (!lock.isHeldByCurrentThread()) {
            key = null;
        }
    }
Create a class and resource specific lock. If another thread has not closed another AutoCloseableReentrantLock
with the same class and resource then this will block until it is closed.

@param clazz    The class for which the lock should be created.
@param resource The resource for which the lock should be created.
xmppserver/src/main/java/org/jivesoftware/util/AutoCloseableReentrantLock.java