C11 Threads simple example

suggest change
#include <stdio.h>
#include <stdlib.h>
#include <threads.h>

int run(void *arg)
{
    (void)arg;
    printf("Hello world of C11 threads.\n");

    return 0;
}

int main(void)
{
    thrd_t thread;
    int result;

    if (thrd_create(&thread, run, NULL) != thrd_success) {
        fputs("thrd_create failed\n", stderr);
        return EXIT_FAILURE;
    }

    if (thrd_join(thread, &result) != thrd_success) {
        fputs("thrd_join failed\n", stderr);
        return EXIT_FAILURE;
    }

    printf("Thread returned %d\n", result);
    return EXIT_SUCCESS;
}

Feedback about page:

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



Table Of Contents