// ----------------------------------------------------
// Sample pthread program 1 by: Thomas Braunl, UWA 2004
// ----------------------------------------------------
#include <pthread.h>
#include <stdio.h>

#define repeats   3
#define threadnum 5

void *slave(void *arg)
{ int id = (int) arg ;

  for (int i = 0; i < repeats; i++) 
  { printf("thread %d\n", id);
    sched_yield();
  }
  return( 0 ) ;
}


int main()
{ pthread_t thread;

  for(int i = 0; i < threadnum ; i++) 
  { if (pthread_create(&thread, NULL, slave, (void *) i)) 
    printf("Error: thread creation failed\n");
  }
  pthread_exit( 0 );
}

