/* ---------------------------------------------------------------- */
/* PROGRAM  ex0.c                                                   */
/*    This program creates two threads and sends each of them an    */
/* integer.  The created thread then displays the argument's value. */
/* ---------------------------------------------------------------- */

#include  <stdio.h>
#include  <thread.h>

void *count(void *JunkPTR)
{
     int  *valuePTR = (int *) JunkPTR;  /* convert to integer ptr.  */
     int  value     = *valuePTR;        /* then take the value      */

     printf("Child: value = %d\n", value);
}

void  main(void)
{
     thread_t  ID1, ID2;                /* for thread IDs           */
     int       v1 = 1;                  /* argument for the 1st thr */
     int       v2 = 2;                  /* argument for the 2nd thr */

     thr_create(NULL, 0, count, (void *) (&v1), 0, &ID1);
     thr_create(NULL, 0, count, (void *) (&v2), 0, &ID2);
     printf("Parent\n");
     sleep(2);                          /* why is sleep() here?     */     
}