Question: Consider the following code snippet: static int tot _ balance = 4 0 0 ; void * deposit _ cash ( void * args )

Consider the following code snippet:
static int tot_balance =400; void *deposit_cash(void *args){ int balance = tot_balance; int *money =(int *) args; printf("[Thread] load: %d, deposit: %d
", balance, *money); sleep(0.1); balance +=*(money); tot_balance = balance; printf("[Thread] final: %d
", tot_balance); } int main(){ int i; int cash[2]={100,200}; pthread_t tid[2]; for (i =0; i <2; i++) pthread_create(&tid[i], NULL, deposit_cash, (void *)&cash[i]); for (i =0; i <2; i++) pthread_join(tid[i], NULL); printf("[Main] total: %d
", tot_balance); return 0; }
What are the possible balance values of this account in the end (choose all that apply)?
Group of answer choices
500
800
600
700
400

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 Programming Questions!