I am just a beginner in Programming using C.For my college project I want to create a multi-threaded server application to which multiple clients can connect and transfer there data which can be saved in a database.
After going through many tutorials I got confused about how to create multiple threads using pthread_create.
Somewhere it was done like:
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 by implementing both in my application and seems to be working fine. Which approach of the above two is correct which I should follow. sorry for bad english and description.
thr[i++]
should be&thr[i++]
. – Hydroquinone