CODE :
#include<iostream>
#include<pthread.h>
#include<string>
using namespace std;
string animals[5] = {"dog", "cat","turkey","shark","lion"};
void *printWord(void *arg ){
int id = *((int*)arg);
cout<<"Current word : "<<animals[id] << endl;
pthread_exit(NULL);
}
int main(){
pthread_t thread_id[5];
for(int num = 0; num < 5; num++){
pthread_create(&thread_id[num],NULL,printWord,(void*)&num);
pthread_join(thread_id[num],NULL);
}
cout<<"Process done!\n";
return 0;
}
Output :
Explanation :
c++ Consider the following C++ code: 7 string animals[5] = {"dog", "cat", "turkey", "shark", "lion"); B...
C Programming - Please Help us! Implementing Load Balancing, the 3 Base Code files are at the bottom: Implementing Load Balancing Summary: In this homework, you will be implementing the main muti-threaded logic for doing batch based server load balancing using mutexes Background In this assignment you will write a batch-based load balancer. Consider a server which handles data proces- sing based on user requests. In general, a server has only a fixed set of hardware resources that it can...