"PThreads c++ Example" Code Answer's

You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "PThreads c++ Example" answered properly. Developers are finding an appropriate answer about PThreads c++ Example related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like PThreads c++ Example. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on PThreads c++ Example. 

PThreads c++ Example

By MauzMauz on Apr 24, 2021
#include <iostream>
#include <cstdlib>
#include <pthread.h>

using namespace std;

#define NUM_THREADS 5

void *PrintHello(void *threadid) {
   long tid;
   tid = (long)threadid;
   cout << "Hello World! Thread ID, " << tid << endl;
   pthread_exit(NULL);
}

int main () {
   pthread_t threads[NUM_THREADS];
   int rc;
   int i;
   
   for( i = 0; i < NUM_THREADS; i++ ) {
      cout << "main() : creating thread, " << i << endl;
      rc = pthread_create(&threads[i], NULL, PrintHello, (void *)i);
      
      if (rc) {
         cout << "Error:unable to create thread," << rc << endl;
         exit(-1);
      }
   }
   pthread_exit(NULL);
}

Source: www.tutorialspoint.com

Add Comment

0

All those coders who are working on the C++ based application and are stuck on PThreads c++ Example can get a collection of related answers to their query. Programmers need to enter their query on PThreads c++ Example related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about PThreads c++ Example for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of PThreads c++ Example while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "PThreads c++ Example". Visit this developer's friendly online web community, CodeProZone, and get your queries like PThreads c++ Example resolved professionally and stay updated to the latest C++ updates. 

C++ answers related to "PThreads c++ Example"

View All C++ queries

C++ queries related to "PThreads c++ Example"

Browse Other Code Languages

CodeProZone