dhilst

Thread Hello World

/*
* File thread_hello.c
* Compiling: gcc -o thread-hello thread_hello.c -lpthread
*/
#include <stdio.h>
#include <pthread.h>

void *
print_hello (void * arg)
{
printf ("Hello World\n");
return NULL;
}

int
main (void)
{
pthread_t thread_1_id;
pthread_create (&thread_1_id, NULL, &print_hello, NULL);
/*
* Main need be the last funtion to return
*/
pthread_join (thread_1_id, NULL);
return 0;
}