Compartilhar via


CountDownLatch.Await Method

Definition

Overloads

Await()

Causes the current thread to wait until the latch has counted down to zero, unless the thread is Thread#interrupt interrupted.

Await(Int64, TimeUnit)

Causes the current thread to wait until the latch has counted down to zero, unless the thread is Thread#interrupt interrupted, or the specified waiting time elapses.

Await()

Causes the current thread to wait until the latch has counted down to zero, unless the thread is Thread#interrupt interrupted.

[Android.Runtime.Register("await", "()V", "GetAwaitHandler")]
public virtual void Await ();
[<Android.Runtime.Register("await", "()V", "GetAwaitHandler")>]
abstract member Await : unit -> unit
override this.Await : unit -> unit
Attributes

Exceptions

if the current thread is interrupted while waiting

Remarks

Causes the current thread to wait until the latch has counted down to zero, unless the thread is Thread#interrupt interrupted.

If the current count is zero then this method returns immediately.

If the current count is greater than zero then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of two things happen: <ul> <li>The count reaches zero due to invocations of the #countDown method; or <li>Some other thread Thread#interrupt interrupts the current thread. </ul>

If the current thread: <ul> <li>has its interrupted status set on entry to this method; or <li>is Thread#interrupt interrupted while waiting, </ul> then InterruptedException is thrown and the current thread's interrupted status is cleared.

Java documentation for java.util.concurrent.CountDownLatch.await().

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

Await(Int64, TimeUnit)

Causes the current thread to wait until the latch has counted down to zero, unless the thread is Thread#interrupt interrupted, or the specified waiting time elapses.

[Android.Runtime.Register("await", "(JLjava/util/concurrent/TimeUnit;)Z", "GetAwait_JLjava_util_concurrent_TimeUnit_Handler")]
public virtual bool Await (long timeout, Java.Util.Concurrent.TimeUnit? unit);
[<Android.Runtime.Register("await", "(JLjava/util/concurrent/TimeUnit;)Z", "GetAwait_JLjava_util_concurrent_TimeUnit_Handler")>]
abstract member Await : int64 * Java.Util.Concurrent.TimeUnit -> bool
override this.Await : int64 * Java.Util.Concurrent.TimeUnit -> bool

Parameters

timeout
Int64

the maximum time to wait

unit
TimeUnit

the time unit of the timeout argument

Returns

true if the count reached zero and false if the waiting time elapsed before the count reached zero

Attributes

Exceptions

if the current thread is interrupted while waiting

Remarks

Causes the current thread to wait until the latch has counted down to zero, unless the thread is Thread#interrupt interrupted, or the specified waiting time elapses.

If the current count is zero then this method returns immediately with the value true.

If the current count is greater than zero then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happen: <ul> <li>The count reaches zero due to invocations of the #countDown method; or <li>Some other thread Thread#interrupt interrupts the current thread; or <li>The specified waiting time elapses. </ul>

If the count reaches zero then the method returns with the value true.

If the current thread: <ul> <li>has its interrupted status set on entry to this method; or <li>is Thread#interrupt interrupted while waiting, </ul> then InterruptedException is thrown and the current thread's interrupted status is cleared.

If the specified waiting time elapses then the value false is returned. If the time is less than or equal to zero, the method will not wait at all.

Java documentation for java.util.concurrent.CountDownLatch.await(long, java.util.concurrent.TimeUnit).

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