ExitThread

ExitThread ends a thread.

Syntax

VOID ExitThread(
    DWORD ExitCode
);

Parameters

ExitCode

The exit code for the calling thread. Use GetExitCodeThread to retrieve a thread's exit code.

Return Value

This function does not return a value.

Remarks

ExitThread is the preferred method of exiting a thread. When this function is called (either explicitly or by returning from a thread procedure), the current thread's stack is de-allocated and the thread terminates.

If the thread is the last thread in the process when this function is called, the thread's process is also terminated.

Terminating a thread does not necessarily remove the thread object from the operating system. A thread object is deleted when the last handle to the thread is closed.

ExitProcess, ExitThread, CreateThread, and a process that is starting are serialized between each other within a process. Only one of these events can occur at a time.

If the primary thread calls ExitThread, the application will exit.

Requirements

Minimum Supported Version RTX64 2013
Header windows.h
Library Rtx_Rtss.lib

See Also:

CreateThread

ExitProcess

GetExitCodeThread

TerminateThread