Skip to content

Instantly share code, notes, and snippets.

@jonathanmarvens
Created November 20, 2013 16:21
Show Gist options
  • Save jonathanmarvens/7566046 to your computer and use it in GitHub Desktop.
Save jonathanmarvens/7566046 to your computer and use it in GitHub Desktop.
#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