Class LockPool<K>

java.lang.Object
ch.tocco.nice2.toolbox.api.LockPool<K>

public final class LockPool<K> extends Object
A pool of keyed locks. The pool makes sure that all user's share the same mapping from a key to a lock while allowing the locks to be garbage collected when unused. Note that using such a thing is bad practice, but may be useful in some seldom cases. ;)

Example Usage

    LockPool.Lock myLock = LockPool.lock("myKey"):
    try {
        // code
    }
    finally {
        myLock.unlock();
    }