In computer science, yield is an action that occurs in a computer program during multithreading, of forcing a processor to relinquish control of the current running thread, and sending it to the end of the running queue, of the same scheduling priority.
Different programming languages implement yielding in various ways.
pthread_yield
in the language C, a low level implementation, provided by POSIX Threads[1]std::this_thread::yield
in the language C++, introduced in C++11.yield
in KotlinCoroutines are a fine-grained concurrency primitive, which may be required to yield explicitly. They may enable specifying another function to take control. Coroutines that explicitly yield allow cooperative multitasking.