Format
#include <stdlib.h> /* also in <process.h> */ void _endthread(void);
Language Level: Extension
_endthread ends a thread that you previously created with
_beginthread. When the thread has finished, it automatically ends
itself with an implicit call to _endthread. You can also call
_endthread explicitly to end the thread before it has completed
its function, for example, if some error condition occurs.
Notes:
Return Value
There is no return value.
Example
In this example, the main program creates two threads,
bonjour and au_revoir.
Note: You must compile this example with the /Gm+ option.
#if (1 == __TOS_OS2__)
#define INCL_DOS /* OS/2 */
#include <os2.h>
#else
#include <windows.h> /* Windows */
#endif
#include <stdio.h> #include <stdlib.h> #include <process.h>
void _Optlink bonjour(void *arg)
{
int i = 0;
while (i++ < 5)
printf("Bonjour!\n");
_endthread(); /* This thread ends itself explicitly */
puts("thread should terminate before printing this");
}
![]()
_beginthread -- Create New Thread
<stdlib.h>
<process.h>
/Gm compiler option