Si blocca lo stesso, l'unica differenza è l'uso di un array di pthread_t...che sia li l'errore? Anche se i thread sono creati correttamente!
codice:
t_id = (pthread_t*) malloc(10*sizeof(pthread_t));
while(running){
if( (acp = acceptConnection(fd_sock)) != -1 ){
t_id[i] = (pthread_t) malloc(sizeof(pthread_t));
thread = pthread_create(t_id[i], NULL, worker, (void*)&acp);
if(thread == -1)
perror("Crezione thread");
}
printf("Thread ok\n");
i++;
if(i >= 9)
realloc(t_id, 10*sizeof(pthread_t) );
}
}
printf("Wait here i vale %d\n", i);
int tmp = 0;
for(tmp = 0; tmp < i ; tmp++){
pthread_join(t_id[tmp], NULL);
}
printf("Wait here\n");
L'output è:
Thread ok (8 volte).
Wait here i vale 8
non termina mai...