TimeUnit.TimedWait(Object, Int64) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Performs a timed Object#wait(long, int) Object.wait
using this time unit.
[Android.Runtime.Register("timedWait", "(Ljava/lang/Object;J)V", "")]
public void TimedWait (Java.Lang.Object? obj, long timeout);
[<Android.Runtime.Register("timedWait", "(Ljava/lang/Object;J)V", "")>]
member this.TimedWait : Java.Lang.Object * int64 -> unit
Parameters
- obj
- Object
the object to wait on
- timeout
- Int64
the maximum time to wait. If less than or equal to zero, do not wait at all.
- Attributes
Exceptions
if interrupted while waiting
Remarks
Performs a timed Object#wait(long, int) Object.wait
using this time unit. This is a convenience method that converts timeout arguments into the form required by the Object.wait
method.
For example, you could implement a blocking poll
method (see BlockingQueue#poll(long, TimeUnit) BlockingQueue.poll
) using:
{@code
public E poll(long timeout, TimeUnit unit)
throws InterruptedException {
synchronized (lock) {
while (isEmpty()) {
unit.timedWait(lock, timeout);
...
}
}
}}
Java documentation for java.util.concurrent.TimeUnit.timedWait(java.lang.Object, long)
.
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.