#include #include #include #include "common.h" #include "common_threads.h" void *mythread(void *arg) { printf("%s\n", (char *) arg); return NULL; } int main(int argc, char *argv[]) { if (argc != 1) { fprintf(stderr, "usage: main\n"); exit(1); } pthread_t p1, p2; printf("main: begin\n"); printf( "main: creating T1\n"); Pthread_create(&p1, NULL, mythread, "A"); printf( "main: creating T2\n"); Pthread_create(&p2, NULL, mythread, "B"); // join waits for the threads to finish printf( "main: waiting for T1\n"); Pthread_join(p1, NULL); printf( "main: waiting for T2\n"); Pthread_join(p2, NULL); printf("main: end\n"); return 0; }