// sem1.cc

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

using namespace std;


void * printvals (void *);

int main ()
{
   pthread_t thread1, thread2;    // two processes
   int odd, even;

   odd = 0;
   pthread_create (&thread1, NULL, printvals, (void *) odd);
   even = 1;
   pthread_create (&thread2, NULL, printvals, (void *) even);

   cout << endl << "Done" << endl;

   return 0;
}


void * printvals (void* ptr)
{
   int i;
   int min, max;
   int even = (int) ptr;

   cout << "in thread, even = " << even << endl;

   if (even) {
      max = 20;
      min = 0;
   } else {
      max = 19;
      min = 1;
   }

   for (i = min; i <= max; i+=2)
      cout << i << " ";
   cout << endl;
}
