#include <stdio.h>
#include <pthread.h>
#include <unistd.h>

#define NUM_THREADS 5
  
void *thread_function(void *arg) {
  printf("Hello World from %d!\n", (int)arg);
  sleep(1);
  pthread_exit(NULL);
}
  
int main(int argc, char *argv[]) {
  int i;
  pthread_t threads[NUM_THREADS];

  for (i = 0; i < NUM_THREADS; i++)
    pthread_create(&threads[i], NULL, thread_function, (void *)i);
  
  for (i = 0; i < NUM_THREADS; i++)
    pthread_join(threads[i], NULL);

  return 0;
}
