Subj : Application hangs in pthread_join To : comp.programming.threads From : Jeff Date : Fri Mar 18 2005 07:53 am I have a multi-threaded application that occasionally hangs as it waits in pthread_join. This is a HTTP load tester (siege) and it tends to happen on GNU/Linux when the thread count exceeds 500. I suspect a thread gets hosed in a socket read and the main thread can't join it. Here is my thread creation and collection: /** * loop until my.cusers and create a corresponding thread... */ for( x = 0; x < my.cusers && our.shutting_down != TRUE; x++ ){ client[x].id = x; client[x].bytes = 0; client[x].time = 0.0; client[x].hits = 0; client[x].code = 0; client[x].fail = 0; client[x].U = urls; client[x].rand_r_SEED = pthread_rand_np(&randrseed); result = pthread_create(&(peer[x]), &scope_attr, (void*)start_routine, &(client[x])); if(result == EAGAIN){ my.verbose = FALSE; joe_fatal("system resources exhausted"); } /** * lock and increment the thread counter */ pthread_mutex_lock( &our.mutex_lock ); if( our.shutting_down != TRUE ){ our.total_clients ++; our.total_threads ++; } pthread_mutex_unlock(&our.mutex_lock); pthread_cond_signal(&our.exit_cond); } /* end of for pthread_create */ /** * our.total_clients is the threads high water * mark; join all the threads that were spawned. */ x = our.total_clients; while(x){ pthread_join(peer[x--], &statusp); <= hangs here! } Any thoughs would be appreciated. Jeff .