I intend to fire 2 threads in the main thread, and the main thread should wait till all the 2 child threads finish, this is how I do it.
void *routine(void *
int main() { pthread_t tid[2]; for (int i = 0; i < 2; i++) { pthread_create(&tid[i], NULL, routine, NULL); } for (int i = 0; i < 2; i++) pthread_join(tid[i], NULL); return 0; }