terminateThread

Syntax

bool terminateThread(int hThread)

Arguments

hThread
Specifies the handle of the thread which we wish to terminate, or 0 to terminate all current worker threads.

Return

Returns true if all specified threads have terminated, or false if an error occurred.

Description

Use this function to terminate one or all worker threads that were created by calling triggerThread. To terminate one particular thread, set the hThread parameter to the value of the thread handle that was returned by the call to triggerThread. To terminate all current worker threads, set the hThread parameter to 0.

Note: This API can be dangerous to use, since forcibly terminating a thread can result in failure to release resources owned by the thread, and DLLs attached to the thread are not notified that the thread is terminating. Use this API only when absolutely necessary. For more details, see the documentation of the Windows [TerminateThread API].

Example

See the example in triggerThread.

Also see

System Functions, Multithreading Functions, countProcessors, triggerThread, waitForThread, isThreadActive, getThreadRetVal

Comments