Question: #include #include #include #define NTHREADS 10 pthread_t threads[NTHREADS]; void go (int n) { printf(Hello from thread %d , n); thread_exit(100 + n); // REACHED? }

#include #include #include #define NTHREADS 10 pthread_t threads[NTHREADS]; void go (int n) { printf("Hello from thread %d ", n); thread_exit(100 + n); // REACHED? } int main() { int i; for (i = 0; i < NTHREADS; i++) thread_create(&threads[i], &go, i); for (i = 0; i < NTHREADS; i++) { int exitValue = thread_join(threads[i]); printf("Thread %d returned with %ld ", i, exitValue); } printf("Main thread done. "); }

Suppose that we delete the second for loop so that the main routine simply creates NTHREADS threads and then prints Main thread done. What are the possible outputs of the program now?

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!