Multithreading

suggest change

Versions

[{“Name”:“C11”,“GroupName”:null}]

Introduction

In C11 there is a standard thread library, <threads.h>, but no known compiler that yet implements it. Thus, to use multithreading in C you must use platform specific implementations such as the POSIX threads library (often referred to as pthreads) using the pthread.h header.

Syntax

Remarks

Using threads can introduce extra undefined behavior such as a https://stackoverflow.com/documentation/c/364/undefined-behavior/2622/data-race#t=201706130820201457052. For race-free access to variables that are shared between different threads C11 provides the mtx_lock() mutex functionality or the (optional) https://stackoverflow.com/documentation/c/4924/atomics#t=201706150835215525448 data-types and associated functions in stdatomic.h.

Feedback about page:

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



Table Of Contents