_beginthread

Starts a new thread of execution.

long _beginthread (int (*start_address)(void *), unsigned stack_size, void * arglist);

long beginthread (int (*start_address)(void *), unsigned stack_size, void * arglist);

Required Header
<process.h>

Return Value

Each of these functions returns a handle to the new thread. -1 indicates an error, where errno will be set to EAGAIN if there are too many threads already running, EINVAL if the stack size or argument list is invalid, or ENOMEM if the new stack could not be allocated.

Parameters

start_address

  A pointer to a function for the new thread to execute

stack_size

  The initial Stack size for the new thread, or zero for the default size of 256K

arglist

  A void * to be passed to the new start_address function when the thread starts

Remarks

The _beginthread function initiates a new thread of execution and runs the function pointed to by start_address. When the function start_address finishes, so too does the new thread.

use _syncthread to wait for the termination of the newly started thread, and to recover the thread-slot for later reuse.

Process and Threads

See Also    _endthread, _syncthread, _threadpriority, _threadstatus