@InterfaceAudience.Private public class KeyLocker<K> extends Object
class Example { private final static KeyLocker<String> locker = new Locker<String>(); public void foo(String s){ Lock lock = locker.acquireLock(s); try { // whatever }finally{ lock.unlock(); } } }
Constructor and Description |
---|
KeyLocker() |
Modifier and Type | Method and Description |
---|---|
ReentrantLock |
acquireLock(K key)
Return a lock for the given key.
|
Map<K,Lock> |
acquireLocks(Set<? extends K> keys)
Acquire locks for a set of keys.
|
public ReentrantLock acquireLock(K key)
key
-