Skip to content

Commit

Permalink
Add files for lecture 17
Browse files Browse the repository at this point in the history
  • Loading branch information
jongchank committed May 9, 2022
1 parent d6a41f3 commit 92f431a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions 17/thread.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

void *mythread(void *arg) {
printf("%s\n", (char *) arg);
return NULL;
}

int main(void)
{
pthread_t p1, p2;
printf("main: begin\n");
pthread_create(&p1, NULL, mythread, "A");
pthread_create(&p2, NULL, mythread, "B");
// join waits for the threads to finish
pthread_join(p1, NULL);
pthread_join(p2, NULL);
printf("main: end\n");
return 0;
}

0 comments on commit 92f431a

Please sign in to comment.