Question: (b) In the following program, the main thread creates four peer threads and passes a pointer to the loop variable to each one. Each peer

 (b) In the following program, the main thread creates four peer
threads and passes a pointer to the loop variable to each one.

(b) In the following program, the main thread creates four peer threads and passes a pointer to the loop variable to each one. Each peer thread prints a message containing the loop variable. S 1 #include 2 #include 3 4 void *foo(void *arg) { int *myid (int *) argi 6 printf("Hello from thread %d ", *myid): 7 return NULL; 8 } 9 10 int main() { 11 pthread_t tid[4]; 12 int i; 13 14 for(i=0; i 2 #include 3 4 void *foo(void *arg) { int *myid (int *) argi 6 printf("Hello from thread %d ", *myid): 7 return NULL; 8 } 9 10 int main() { 11 pthread_t tid[4]; 12 int i; 13 14 for(i=0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!