logo

Crowdly

Browser

Додати до Chrome

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

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

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 }

Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на moodle.nu.edu.kz?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!

Browser

Додати до Chrome