_endthread

end a thread of execution

Synopsis:

#include <process.h>
void _endthread(void);

Description:

The _endthread() function is used to terminate a thread created by _beginthread(). For each operating environment on which _endthread() is supported, the _endthread() function uses the appropriate system call to end the current thread of execution.

The QNX libraries currently aren't completely thread-safe. If you need to use this functionality, contact Technical Support to see if newer versions of the libraries are available.

See also:

_beginthread(), _threadid

Examples:

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <process.h>

#define  STACK_SIZE   4096
#if defined(__386__)
  #define FAR
#else
  #define FAR __far
#endif

volatile thread_count = 0;

void FAR child( void FAR *parm )
  {
    char * FAR *argv = (char * FAR *) parm;
    int  i;

    for( i = 0; argv[i]; i++ ) {
      printf( "argv[%d] = %s\n", i, argv[i] );
    }
    thread_count--;
    _endthread();
  }

void main()
  {
    char *stack;
    char *args[3];
    int   tid;
    int   status;

    args[0] = "child";
    args[1] = "parm";
    args[2] = NULL;
    stack = (char *) _nmalloc( STACK_SIZE );
    thread_count++;
    tid = _beginthread( child, stack, STACK_SIZE, args );
    while( thread_count );
  }

Classification:

WATCOM

Systems:

NT, OS2 (DL), OS2 (MT), OS/2-32, Netware, QNX