Created
April 8, 2018 13:38
-
-
Save tarunjain07/7e815c77b2ece08c694fa3f1e5b4d58f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* PThread Creation */ | |
#include <stdio.h> | |
#include <pthread.h> | |
void *foo (void *arg) { /* thread main */ | |
printf("Foobar!\n"); | |
pthread_exit(NULL); | |
} | |
int main (void) { | |
int i; | |
pthread_t tid; | |
pthread_attr_t attr; | |
pthread_attr_init(&attr); // Required!!! | |
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); | |
pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); | |
pthread_create(&tid, &attr, foo, NULL); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment