logo

Crowdly

Browser

Add to Chrome

Select the correct “ Final Balance ”  of the following program:   1 #include <...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Select the correct “Final Balance”  of the following program:

  1 #include <stdio.h>

  2 #include <pthread.h>

  3

  4 int balance = 0;

  5

  6 void* mythread(void *arg){

  7 int i;

  8 for(i=0; i<200; i++){

  9     balance++;

 10 }

 11 printf("balance is %d\n", balance);

 12 return NULL;

 13 }

 14

 15 int main(){

 16 pthread_t p1, p2, p3;

 17

 18 pthread_create(&p1, NULL, mythread, "A");

 19 pthread_join(p1, NULL);

 20 balance+=10;

 21

 22 pthread_create(&p2, NULL, mythread, "B");

 23 pthread_join(p2, NULL);

 24 balance+=20;

 25

 26 pthread_create(&p3, NULL, mythread, "C");

 27 pthread_join(p3, NULL);

 28 balance+=30;

 29

 30 printf("Final Balance is %d\n", balance);

 31

32 return 0;

 33 }

More questions like this

Want instant access to all verified answers on moodle.nu.edu.kz?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome