Share via


ReentrantReadWriteLock.ReentrantWriteLock.NewCondition Method

Definition

Returns a Condition instance for use with this Lock instance.

[Android.Runtime.Register("newCondition", "()Ljava/util/concurrent/locks/Condition;", "GetNewConditionHandler")]
public virtual Java.Util.Concurrent.Locks.ICondition? NewCondition ();
[<Android.Runtime.Register("newCondition", "()Ljava/util/concurrent/locks/Condition;", "GetNewConditionHandler")>]
abstract member NewCondition : unit -> Java.Util.Concurrent.Locks.ICondition
override this.NewCondition : unit -> Java.Util.Concurrent.Locks.ICondition

Returns

the Condition object

Implements

Attributes

Remarks

Returns a Condition instance for use with this Lock instance.

The returned Condition instance supports the same usages as do the Object monitor methods (Object#wait() wait, Object#notify notify, and Object#notifyAll notifyAll) when used with the built-in monitor lock.

<ul>

<li>If this write lock is not held when any Condition method is called then an IllegalMonitorStateException is thrown. (Read locks are held independently of write locks, so are not checked or affected. However it is essentially always an error to invoke a condition waiting method when the current thread has also acquired read locks, since other threads that could unblock it will not be able to acquire the write lock.)

<li>When the condition Condition#await() waiting methods are called the write lock is released and, before they return, the write lock is reacquired and the lock hold count restored to what it was when the method was called.

<li>If a thread is Thread#interrupt interrupted while waiting then the wait will terminate, an InterruptedException will be thrown, and the thread's interrupted status will be cleared.

<li>Waiting threads are signalled in FIFO order.

<li>The ordering of lock reacquisition for threads returning from waiting methods is the same as for threads initially acquiring the lock, which is in the default case not specified, but for <em>fair</em> locks favors those threads that have been waiting the longest.

</ul>

Java documentation for java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock.newCondition().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to