Last active
April 8, 2018 13:55
-
-
Save tarunjain07/f1017ed781c09bd762eb0029c4aecf6a 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 Quiz 1 */ | |
#include <stdio.h> | |
#include <pthread.h> | |
#define NUM_THREADS 4 | |
void *hello (void *arg) { /* thread main */ | |
printf("Hello Thread\n"); | |
return 0; | |
} | |
int main (void) { | |
int i; | |
pthread_t tid[NUM_THREADS]; | |
for (i = 0; i < NUM_THREADS; i++) { /* create/fork threads */ | |
pthread_create(&tid[i], NULL, hello, NULL); | |
} | |
for (i = 0; i < NUM_THREADS; i++) { /* wait/join threads */ | |
pthread_join(tid[i], NULL); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment