Question: void * mythread ( void * arg ) { printf ( % s , ( char * ) arg ) ; return Null;

void *mythread(void *arg){
printf("%s
",(char *) arg);
return Null;
}
int
main(int argc, char *argv[]){
pthread_t p1, p2;
int rc;
printf("main: begin
");
Pthread_create(&p1, NULL, mythread, "A");
Pthread_create(&p2, NULL, mythread, "B");
Pthread_join(p1, NULL);
Pthread_join(p2, NULL);
printf("main: end
");
return 0;
}
Above C program starts off two worker threads P1 and P2 to print out a letter "A" and "B" respectively. If the two lines highlighted in RED are removed, what is likely to happen compared with the output of existing program?
thread p1 and p2 will not be started
Letter "A" or "B" will be printed in indeterministic order
Both "A" and "B" are printed, or either "A" or "B" is printed, or neither is printed.
"main: end" will notbeprintedout

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!