Sdílet prostřednictvím


Thread.Yield Method

Definition

A hint to the scheduler that the current thread is willing to yield its current use of a processor.

[Android.Runtime.Register("yield", "()V", "")]
public static void Yield ();
[<Android.Runtime.Register("yield", "()V", "")>]
static member Yield : unit -> unit
Attributes

Remarks

A hint to the scheduler that the current thread is willing to yield its current use of a processor. The scheduler is free to ignore this hint.

Yield is a heuristic attempt to improve relative progression between threads that would otherwise over-utilise a CPU. Its use should be combined with detailed profiling and benchmarking to ensure that it actually has the desired effect.

It is rarely appropriate to use this method. It may be useful for debugging or testing purposes, where it may help to reproduce bugs due to race conditions. It may also be useful when designing concurrency control constructs such as the ones in the java.util.concurrent.locks package.

Java documentation for java.lang.Thread.yield().

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