Multithreading

suggest change

C11 added a standard threading API in <threads.h>. It includes threads (thrd_t), mutexes (mtx_t), condition variables (cnd_t), one-time initialization (once_flag), and thread-specific storage (tss_t).

The API is optional. An implementation that does not provide it defines __STDC_NO_THREADS__; otherwise, a program can include <threads.h>. Support depends on the C implementation and its standard library, so check the documentation and link options for the target platform.

The central operations are:

Unsynchronized conflicting accesses to the same object from different threads cause a data race and undefined behavior. Use mutexes or the atomic operations in <stdatomic.h> when objects are shared between threads. volatile is not a synchronization mechanism.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents