Chapter 58: Multithreading

No Comments

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.

Section 58.1: C11 Threads simple example

#include <threads.h>

#include <stdio.h>

int run(void *arg)

{

printf(“Hello  world  of  C11  threads.”);

return  0;

}

int main(int argc, const char *argv[])

{

thrd_t thread;

int result;

thrd_create(&thread,  run,  NULL);

thrd_join(&thread,  &result);

printf(“Thread  return  %d  at  the  end\n“,  result);

}

About us and this blog

We are a digital marketing company with a focus on helping our customers achieve great results across several key areas.

Request a free quote

We offer professional SEO services that help websites increase their organic search score drastically in order to compete for the highest rankings even when it comes to highly competitive keywords.

Subscribe to our newsletter!

More from our blog

See all posts
No Comments