Created
November 20, 2013 16:21
-
-
Save jonathanmarvens/7566046 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <assert.h> | |
#include <pthread.h> | |
#include <stdio.h> | |
void *function(void *argument) { | |
printf("%s\n", (char *) argument); | |
return NULL; | |
} | |
int main(int arguments_count, char *arguments_vector[]) { | |
pthread_t t1; | |
pthread_t t2; | |
int return_code; | |
printf("begin <main> ---\n"); | |
return_code = pthread_create(&t1, NULL, function, "A"); | |
assert(return_code == 0); | |
return_code = pthread_create(&t2, NULL, function, "B"); | |
assert(return_code == 0); | |
return_code = pthread_join(t1, NULL); | |
assert(return_code == 0); | |
return_code = pthread_join(t2, NULL); | |
assert(return_code == 0); | |
printf("end <main> ---\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment