You are viewing a single comment's thread from:

RE: Networking - C Threads in Linux

in #networking6 years ago

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);
}

Sort:  

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 :)

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.030
BTC 64407.71
ETH 3414.50
USDT 1.00
SBD 2.62