Lines Matching refs:lock

17  * <p>A lock is a tool for controlling access to a shared resource by
18 * multiple threads. Commonly, a lock provides exclusive access to a
19 * shared resource: only one thread at a time can acquire the lock and
20 * all access to the shared resource requires that the lock be
22 * a shared resource, such as the read lock of a {@link ReadWriteLock}.
25 * access to the implicit monitor lock associated with every object, but
26 * forces all lock acquisition and release to occur in a block-structured way:
38 * acquire the lock of node A, then node B, then release A and acquire
41 * allowing a lock to be acquired and released in different scopes,
52 * l.lock();
54 * // access the resource protected by this lock
61 * taken to ensure that all code that is executed while the lock is
63 * lock is released when necessary.
67 * providing a non-blocking attempt to acquire a lock ({@link
68 * #tryLock()}), an attempt to acquire the lock that can be
70 * the lock that can timeout ({@link #tryLock(long, TimeUnit)}).
73 * that is quite different from that of the implicit monitor lock,
81 * monitor lock of a {@code Lock} instance has no specified relationship
82 * with invoking any of the {@link #lock} methods of that instance.
94 * lock, as described in <a href="http://java.sun.com/docs/books/jls/">
97 * <li>A successful {@code lock} operation has the same memory
109 * <p> The three forms of lock acquisition (interruptible,
113 * acquisition of a lock may not be available in a given {@code Lock}
116 * lock acquisition, nor is it required to support interruption of an
117 * ongoing lock acquisition. An implementation is required to clearly
120 * defined in this interface, to the extent that interruption of lock
140 * Acquires the lock.
142 * <p>If the lock is not available then the current thread becomes
144 * lock has been acquired.
149 * of the lock, such as an invocation that would cause deadlock, and
154 void lock();
157 * Acquires the lock unless the current thread is
160 * <p>Acquires the lock if it is available and returns immediately.
162 * <p>If the lock is not available then the current thread becomes
167 * <li>The lock is acquired by the current thread; or
169 * current thread, and interruption of lock acquisition is supported.
176 * lock, and interruption of lock acquisition is supported,
183 * <p>The ability to interrupt a lock acquisition in some
193 * erroneous use of the lock, such as an invocation that would
199 * interrupted while acquiring the lock (and interruption
200 * of lock acquisition is supported).
205 * Acquires the lock only if it is free at the time of invocation.
207 * <p>Acquires the lock if it is available and returns immediately
209 * If the lock is not available then this method will return
214 * Lock lock = ...;
215 * if (lock.tryLock()) {
219 * lock.unlock();
225 * This usage ensures that the lock is unlocked if it was acquired, and
226 * doesn't try to unlock if the lock was not acquired.
228 * @return {@code true} if the lock was acquired and
234 * Acquires the lock if it is free within the given waiting time and the
237 * <p>If the lock is available this method returns immediately
239 * If the lock is not available then
243 * <li>The lock is acquired by the current thread; or
245 * current thread, and interruption of lock acquisition is supported; or
249 * <p>If the lock is acquired then the value {@code true} is returned.
255 * the lock, and interruption of lock acquisition is supported,
267 * <p>The ability to interrupt a lock acquisition in some implementations
277 * erroneous use of the lock, such as an invocation that would cause
282 * @param time the maximum time to wait for the lock
284 * @return {@code true} if the lock was acquired and {@code false}
285 * if the waiting time elapsed before the lock was acquired
288 * while acquiring the lock (and interruption of lock
294 * Releases the lock.
299 * restrictions on which thread can release a lock (typically only the
300 * holder of the lock can release it) and may throw
311 * <p>Before waiting on the condition the lock must be held by the
313 * A call to {@link Condition#await()} will atomically release the lock
314 * before waiting and re-acquire the lock before the wait returns.