On this page
  1. thrd_create
  2. Include
  3. Signature & Overview
  4. Notes & Pitfalls
  5. Example

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

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