Question: #include #include thread.h static void go(int n); #define NTHREADS 10 static thread_t threads[NTHREADS]; int main(int argc, char **argv) { int i; long exitValue; for (i
#include#include "thread.h"
static void go(int n);
#define NTHREADS 10 static thread_t threads[NTHREADS];
int main(int argc, char **argv) { int i; long exitValue;
for (i = 0; i < NTHREADS; i++){ thread_create(&(threads[i]), &go, i); } for (i = 0; i < NTHREADS; i++){ exitValue = thread_join(threads[i]); printf("Thread %d returned with %ld ", i, exitValue);
} printf("Main thread done. "); return 0; }
void go(int n) { printf("Hello from thread %d ", n); thread_exit(100 + n); // Not reached }
rewrite program using pthreads and compile using gcc
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
