// g++  thread.cpp -lpthread -o thread

#include <iostream>
#include <cstdlib>
#include <pthread.h>

using namespace std;

#define NUM_THREADS 5

//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
void *server(void *prt) {
   long PORT;
   PORT = (long)prt;
   cout << "Hello World! Thread with port, " << PORT << endl;
   //--------------------------------
   // You put your code for the server here
   //-----------------------------
   
   pthread_exit(NULL);
}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

int main () {
   pthread_t threads[NUM_THREADS];
   int rc1,rc2;
   int port1=8080;
   int port2=3606;
   
      rc1 = pthread_create(&threads[0], NULL, server, (void *)port1);
      rc2 = pthread_create(&threads[0], NULL, server, (void *)port2);
      
      // if error happens this part will tell you
      if (rc1 || rc2 ) {
         cout << "Error:unable to create thread," << endl;
         exit(-1);
      }
   pthread_exit(NULL);
}
