T- The generic type for the "name". This MUST implement hashCode() and equals() since the instances of this type will serve as keys in a
public class NamedLock<T> extends Object
Locks. A simple
Lockmanages access to a single resource. However, a
NamedLockmanages access to the members of a set of named resources. This is more efficient when the latency of the operation once the lock is acquired is significant, e.g., an RMI call or a disk IO.
The locks are stored in a
WeakHashMap so that they will be garbage
collected if there are no threads waiting in the queue for a given named
|Constructor and Description|
|Modifier and Type||Method and Description|
Block until the
Return the canonical instance of the lock for a named resource.
protected Lock lockFactory(T name)
name- The name.
public Lock acquireLock(T name)
Lockfor the named resource is available, then
Lockand return the locked
name- The name of the resource whose
Lock. It will have already been
public Lock acquireLock(T name, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.