You are viewing a single comment's thread from:
RE: Networking - C Threads in Linux
Thanks @drifter1 for detailed explanation. Could you please tell me what happens below. I think I confused with thread joining.
for(i = 0; i < N; i++){
pthread_join(threads[i], NULL);
}
Haha of course...
When a process or thread runs the main process/thread that created it must finish after it.
For threads we use the function pthread_join() with an important parameter being the thread_id (the number which represents the thread in the Operating system).
So, because we have N threads and because the id's are stored in an array, we have a for loop so that the main process/thread waits for all of them :)