I'm just starting to program using C. For my college project, I want to create a multi-threaded server application to which several clients can connect and transfer there data that can be stored in a database.
After going through many lessons, I was confused about how to create multiple threads using pthread_create.
Somewhere this was done as:
pthread_t thr;
pthread_create( &thr, NULL , connection_handler , (void*)&conn_desc);
and somewhere it was like
pthread_t thr[10];
pthread_create( thr[i++], NULL , connection_handler , (void*)&conn_desc);
I tried to implement both in my application and it seems to work fine. Which approach of these two rules is correct, and I must follow. Sorry for the poor english and description.
source
share