@InterfaceAudience.Private public class KeyLocker<K> extends java.lang.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 |
|---|---|
java.util.concurrent.locks.ReentrantLock |
acquireLock(K key)
Return a lock for the given key.
|
java.util.Map<K,java.util.concurrent.locks.Lock> |
acquireLocks(java.util.Set<? extends K> keys)
Acquire locks for a set of keys.
|
public java.util.concurrent.locks.ReentrantLock acquireLock(K key)
key -