Lines Matching refs:lock

43  * behavior and semantics as the implicit monitor lock accessed using
49 * {@code lock} will return, successfully acquiring the lock, when
50 * the lock is not owned by another thread. The method will return
51 * immediately if the current thread already owns the lock. This can
58 * thread. Otherwise this lock does not guarantee any particular
65 * fair lock may obtain it multiple times in succession while other
67 * lock.
69 * honor the fairness setting. It will succeed if the lock
73 * follow a call to {@code lock} with a {@code try} block, most
78 * private final ReentrantLock lock = new ReentrantLock();
82 * lock.lock(); // block until condition holds
86 * lock.unlock()
99 * locks: a deserialized lock is in the unlocked state, regardless of
102 * <p>This lock supports a maximum of 2147483647 recursive locks by
115 * Base of synchronization control for this lock. Subclassed
117 * represent the number of holds on the lock.
123 * Performs {@link Lock#lock}. The main reason for subclassing
126 abstract void lock();
145 throw new Error("Maximum lock count exceeded");
190 * Reconstitutes this lock instance from a stream.
207 * Performs lock. Try immediate barge, backing up to normal
210 final void lock() {
228 final void lock() {
249 throw new Error("Maximum lock count exceeded");
269 * @param fair {@code true} if this lock should use a fair ordering policy
276 * Acquires the lock.
278 * <p>Acquires the lock if it is not held by another thread and returns
279 * immediately, setting the lock hold count to one.
281 * <p>If the current thread already holds the lock then the hold
284 * <p>If the lock is held by another thread then the
286 * purposes and lies dormant until the lock has been acquired,
287 * at which time the lock hold count is set to one.
289 public void lock() {
290 sync.lock();
294 * Acquires the lock unless the current thread is
297 * <p>Acquires the lock if it is not held by another thread and returns
298 * immediately, setting the lock hold count to one.
300 * <p>If the current thread already holds this lock then the hold count
303 * <p>If the lock is held by another thread then the
309 * <li>The lock is acquired by the current thread; or
316 * <p>If the lock is acquired by the current thread then the lock hold
326 * the lock,
335 * interrupt over normal or reentrant acquisition of the lock.
344 * Acquires the lock only if it is not held by another thread at the time
347 * <p>Acquires the lock if it is not held by another thread and
349 * lock hold count to one. Even when this lock has been set to use a
351 * immediately acquire the lock if it is available, whether or not
352 * other threads are currently waiting for the lock.
355 * the fairness setting for this lock, then use
359 * <p> If the current thread already holds this lock then the hold
362 * <p>If the lock is held by another thread then this method will return
365 * @return {@code true} if the lock was free and was acquired by the
366 * current thread, or the lock was already held by the current
374 * Acquires the lock if it is not held by another thread within the given
378 * <p>Acquires the lock if it is not held by another thread and returns
379 * immediately with the value {@code true}, setting the lock hold count
380 * to one. If this lock has been set to use a fair ordering policy then
381 * an available lock <em>will not</em> be acquired if any other threads
382 * are waiting for the lock. This is in contrast to the {@link #tryLock()}
384 * a fair lock then combine the timed and un-timed forms together:
386 * <pre>if (lock.tryLock() || lock.tryLock(timeout, unit) ) { ... }
390 * already holds this lock then the hold count is incremented by one and
393 * <p>If the lock is held by another thread then the
399 * <li>The lock is acquired by the current thread; or
408 * <p>If the lock is acquired then the value {@code true} is returned and
409 * the lock hold count is set to one.
418 * acquiring the lock,
430 * interrupt over normal or reentrant acquisition of the lock, and
433 * @param timeout the time to wait for the lock
435 * @return {@code true} if the lock was free and was acquired by the
436 * current thread, or the lock was already held by the current
438 * the lock could be acquired
449 * Attempts to release this lock.
451 * <p>If the current thread is the holder of this lock then the hold
452 * count is decremented. If the hold count is now zero then the lock
454 * lock then {@link IllegalMonitorStateException} is thrown.
457 * hold this lock
471 * monitor lock.
475 * <li>If this lock is not held when any of the {@link Condition}
481 * methods are called the lock is released and, before they
482 * return, the lock is reacquired and the lock hold count restored
492 * <li>The ordering of lock reacquisition for threads returning
494 * acquiring the lock, which is in the default case not specified,
507 * Queries the number of holds on this lock by the current thread.
509 * <p>A thread has a hold on a lock for each lock action that is not
514 * not be entered with the lock already held then we can assert that
519 * ReentrantLock lock = new ReentrantLock();
522 * assert lock.getHoldCount() == 0;
523 * lock.lock();
527 * lock.unlock();
533 * @return the number of holds on this lock by the current thread,
534 * or zero if this lock is not held by the current thread
541 * Queries if this lock is held by the current thread.
546 * a lock is held can assert that this is the case:
550 * ReentrantLock lock = new ReentrantLock();
554 * assert lock.isHeldByCurrentThread();
560 * <p>It can also be used to ensure that a reentrant lock is used
565 * ReentrantLock lock = new ReentrantLock();
569 * assert !lock.isHeldByCurrentThread();
570 * lock.lock();
574 * lock.unlock();
580 * @return {@code true} if current thread holds this lock and
588 * Queries if this lock is held by any thread. This method is
592 * @return {@code true} if any thread holds this lock and
600 * Returns {@code true} if this lock has fairness set true.
602 * @return {@code true} if this lock has fairness set true
609 * Returns the thread that currently owns this lock, or
612 * best-effort approximation of current lock status. For example,
614 * threads trying to acquire the lock but have not yet done so.
616 * subclasses that provide more extensive lock monitoring
626 * Queries whether any threads are waiting to acquire this lock. Note that
629 * acquire this lock. This method is designed primarily for use in
633 * acquire the lock
642 * lock. Note that because cancellations may occur at any time, a
644 * will ever acquire this lock. This method is designed primarily for use
648 * @return {@code true} if the given thread is queued waiting for this lock
658 * acquire this lock. The value is only an estimate because the number of
664 * @return the estimated number of threads waiting for this lock
672 * acquire this lock. Because the actual set of threads may change
687 * associated with this lock. Note that because timeouts and
695 * @throws IllegalMonitorStateException if this lock is not held
697 * not associated with this lock
710 * given condition associated with this lock. Note that because
718 * @throws IllegalMonitorStateException if this lock is not held
720 * not associated with this lock
733 * waiting on the given condition associated with this lock.
743 * @throws IllegalMonitorStateException if this lock is not held
745 * not associated with this lock
757 * Returns a string identifying this lock, as well as its lock state.
762 * @return a string identifying this lock, as well as its lock state