#include #include void *new_thread (void *p) { int *n = p; int num = *n; printf("In thread %d\n", num); return p; //or pthread_exit(p); } int main () { pthread_t t1, t2; int n1 = 1, n2 = 5, *status1, *status2; pthread_create(&t1, NULL, new_thread, (void *) &n1); pthread_create(&t2, NULL, new_thread, (void *) &n2); pthread_join(t1, (void *) &status1); //wait till thread t1 ends pthread_join(t2, (void *) &status2); printf("Collected status: %d %d\n", *status1, *status2); return 0; }