/* * CS360: * Jim Plank * p4b.c */ #include #include void *printme(i) int *i; { printf("Hi. I'm thread %d\n", *i); pthread_exit(NULL); } main() { int i, vals[4]; pthread_t tids[4]; void *retval; for (i = 0; i < 4; i++) { vals[i] = i; pthread_create(tids+i, NULL, printme, vals+i); } pthread_exit(NULL); for (i = 0; i < 4; i++) { printf("Trying to join with tid %d\n", i); pthread_join(tids[i], &retval); printf("Joined with tid %d\n", i); } }