|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Defined in header <threads.h> | ||
int thrd_create(thrd_t*thr,thrd_start_t func,void*arg); | (since C11) | |
Creates a new thread executing the functionfunc. The function is invoked asfunc(arg).
If successful, the object pointed to bythr is set to the identifier of the new thread.
The completion of this functionsynchronizes-with the beginning of the thread.
Contents |
| thr | - | pointer to memory location to put the identifier of the new thread |
| func | - | function to execute |
| arg | - | argument to pass to the function |
thrd_success if the creation of the new thread was successful. Otherwise returnsthrd_nomem if there was insufficient amount of memory orthrd_error if another error occurred.
The thread identifiers may be reused for new threads once the thread has finished and joined or detached.
The typethrd_start_t is a typedef ofint(*)(void*), which differs from the POSIX equivalentvoid*(*)(void*)
All thread-specific storage values (seetss_create) are initialized toNULL.
Return from the functionfunc is equivalent to callingthrd_exit with the argument equal to the return value offunc.
(C11) | detaches a thread (function)[edit] |
(C11) | blocks until a thread terminates (function)[edit] |
C++ documentation forthread | |