Causes the calling thread to yield execution to another thread that is ready to run on the current processor. The operating system selects the next thread to be executed.
Syntax
BOOL WINAPI SwitchToThread(void);
Parameters
This function has no parameters.
Return Value
If calling the
SwitchToThread function causes the operating system to switch execution to another thread, the return value is nonzero.
If there are no other threads ready to execute, the operating system does not switch execution to another thread, and the return value is zero.
Remarks
The yield of execution is in effect for up to one thread-scheduling time slice. After that, the operating system reschedules execution for the yielding thread. The rescheduling is determined by the priority of the yielding thread and the status of other threads that are available to run.
Note The yield of execution is limited to the processor of the calling thread. The operating system will not switch execution to another processor, even if that processor is idle or is running a thread of lower priority.
To compile an application that uses this function, define _WIN32_WINNT as 0x0400 or later. For more information, see
Using the Windows Headers.
Requirements
| Minimum supported client | Windows 2000 Professional |
| Minimum supported server | Windows 2000 Server |
| Header | Winbase.h (include Windows.h) |
| Library | Kernel32.lib |
| DLL | Kernel32.dll |
See Also
- Process and Thread Functions
- SuspendThread
- Suspending Thread Execution
- Threads
Send comments about this topic to Microsoft
Build date: 10/8/2009