Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <process.h>
    void _endthread(void);
    void _endthreadex( unsigned retval );

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

    The  _endthreadex function is used to terminate a thread created by
     _beginthreadex.  The thread exit code retval must be specified.

Returns:
    The _endthread function does not return any value.

Example:
    #include <stdio.h>
    #include <stdlib.h>
    #include <stddef.h>
    #include <malloc.h>
    #include <process.h>
    #include <dos.h>

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

    static volatile int     WaitForThread;

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

        printf( "Child thread ID = %x\n", *_threadid );
        for( i = 0; argv[i]; i++ ) {
          printf( "argv[%d] = %s\n", i, argv[i] );
        }
        WaitForThread = 0;
        _endthread();
      }

    void main()
      {
        char           *args[3];
    #if defined(__NT__)
        unsigned long   tid;
    #else
        char           *stack;
        int             tid;
    #endif

        args[0] = "child";
        args[1] = "parm";
        args[2] = NULL;
        WaitForThread = 1;
    #if defined(__NT__)
        tid = _beginthread( child, STACK_SIZE, args );
        printf( "Thread handle = %lx\n", tid );
    #else
      #if defined(__386__)
        stack = (char *) malloc( STACK_SIZE );
      #else
        stack = (char *) _nmalloc( STACK_SIZE );
      #endif
        tid = _beginthread( child, stack, STACK_SIZE, args );
        printf( "Thread ID = %x\n", tid );
    #endif
        while( WaitForThread ) {
            sleep( 0 );
        }
      }

Classification:
    WATCOM

Systems:
     _endthread - Win32, QNX/32, OS/2 1.x(MT), OS/2 1.x(DL), OS/2-32,
    Netware

    _endthreadex - Win32

See Also:
    _beginthread

See Also: _beginthread

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson