terminate_thread


bool terminate_thread(handle thread,
                      unsigned exit_code)

This function terminates a thread.

Parameters

handle thread

The handle of the thread to terminate.

unsigned exit_code

The exit code for the thread.

Return

bool

true The function succeeded.
false The call failed.

Notes

after termination of the thread, the exit code may be determined via the function get_thread_exit_code.

The memory consumed by the thread's stack is not deallocated upon termination. Any dynamic link libraries that are attached are not notified of the thread's termination.

This method is not the recommended approach to ending a thread. The following may result:

Even though the thread has been terminated, it still remains in the system until its last handle has been closed via the function close_handle.

If the thread being terminated is the last thread in the process, the process is also terminated.

Any handles for the thread enter the signalled state upon termination.

The recommended approach for a thread to terminate itself is: