On this page
thrd_create
Prev: threads.h | Up: threads.h | Next: mtx_lock
Rel: threads.h, Concurrency vs. Parallelism
Ref: cppreference — thrd_create
Tags: #public #prog #c #stdlib #threads #tier/specialized
Include
#include <threads.h>
Signature & Overview
int thrd_create(thrd_t *thr, thrd_start_t func, void *arg); /* + thrd_join */
Spawns a new OS thread running func(arg) and waits for completion via thrd_join(thr, &res).
Notes & Pitfalls
- C11 threads (
<threads.h>): Alwaysthrd_join()orthrd_detach(); unavailable on macOS (usepthread_create()).
Example
// C11 <threads.h> pattern:
// int worker(void *arg) { return 0; }
// thrd_t t; thrd_create(&t, worker, NULL); thrd_join(t, NULL);
Linked from
Related notes
- tuts/c/stdlib/threads/mtx_lock Linked here; links to this page; shared tags: #c, #prog, #stdlib, #threads, #tier
- tuts/c/stdlib/threads Linked here; links to this page; shared tags: #c, #prog, #stdlib, #threads
- tuts/programming/concurrency/concurrency_vs_parallelism Linked here; shared tags: #prog
- tuts/c/stdlib/assert/assert shared tags: #c, #prog, #stdlib, #tier
- tuts/c/stdlib/assert/static_assert shared tags: #c, #prog, #stdlib, #tier
- tuts/c/stdlib/ctype/isalpha shared tags: #c, #prog, #stdlib, #tier
- tuts/c/stdlib/ctype/isdigit shared tags: #c, #prog, #stdlib, #tier
- tuts/c/stdlib/ctype/isspace shared tags: #c, #prog, #stdlib, #tier
- tuts/c/stdlib/ctype/tolower shared tags: #c, #prog, #stdlib, #tier
- tuts/c/stdlib/errno/errno shared tags: #c, #prog, #stdlib, #tier