Udostępnij za pośrednictwem


LockSupport.ParkNanos Method

Definition

Overloads

ParkNanos(Int64)

Disables the current thread for thread scheduling purposes, for up to the specified waiting time, unless the permit is available.

ParkNanos(Object, Int64)

Disables the current thread for thread scheduling purposes, for up to the specified waiting time, unless the permit is available.

ParkNanos(Int64)

Disables the current thread for thread scheduling purposes, for up to the specified waiting time, unless the permit is available.

[Android.Runtime.Register("parkNanos", "(J)V", "")]
public static void ParkNanos (long nanos);
[<Android.Runtime.Register("parkNanos", "(J)V", "")>]
static member ParkNanos : int64 -> unit

Parameters

nanos
Int64

the maximum number of nanoseconds to wait

Attributes

Remarks

Disables the current thread for thread scheduling purposes, for up to the specified waiting time, unless the permit is available.

If the specified waiting time is zero or negative, the method does nothing. Otherwise, if the permit is available then it is consumed and the call returns immediately; otherwise the current thread becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:

<ul> <li>Some other thread invokes #unpark unpark with the current thread as the target; or

<li>Some other thread Thread#interrupt interrupts the current thread; or

<li>The specified waiting time elapses; or

<li>The call spuriously (that is, for no reason) returns. </ul>

This method does <em>not</em> report which of these caused the method to return. Callers should re-check the conditions which caused the thread to park in the first place. Callers may also determine, for example, the interrupt status of the thread, or the elapsed time upon return.

Java documentation for java.util.concurrent.locks.LockSupport.parkNanos(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.

Applies to

ParkNanos(Object, Int64)

Disables the current thread for thread scheduling purposes, for up to the specified waiting time, unless the permit is available.

[Android.Runtime.Register("parkNanos", "(Ljava/lang/Object;J)V", "")]
public static void ParkNanos (Java.Lang.Object? blocker, long nanos);
[<Android.Runtime.Register("parkNanos", "(Ljava/lang/Object;J)V", "")>]
static member ParkNanos : Java.Lang.Object * int64 -> unit

Parameters

blocker
Object

the synchronization object responsible for this thread parking

nanos
Int64

the maximum number of nanoseconds to wait

Attributes

Remarks

Disables the current thread for thread scheduling purposes, for up to the specified waiting time, unless the permit is available.

If the specified waiting time is zero or negative, the method does nothing. Otherwise, if the permit is available then it is consumed and the call returns immediately; otherwise the current thread becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:

<ul> <li>Some other thread invokes #unpark unpark with the current thread as the target; or

<li>Some other thread Thread#interrupt interrupts the current thread; or

<li>The specified waiting time elapses; or

<li>The call spuriously (that is, for no reason) returns. </ul>

This method does <em>not</em> report which of these caused the method to return. Callers should re-check the conditions which caused the thread to park in the first place. Callers may also determine, for example, the interrupt status of the thread, or the elapsed time upon return.

Added in 1.6.

Java documentation for java.util.concurrent.locks.LockSupport.parkNanos(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.

Applies to