// gcc -pthread -o exo1 exo1.c

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> // sleep
#include <pthread.h>

char* str_g = "Global";

void* my_thread_process (void* arg) {
  char* str_l = "Local";
  printf("Local : %s\n", str_l);
  printf("Global : %s\n", str_g);
  pthread_exit (0);
}

void* my_thread_process3 (void* arg) {
  char* str_l = "Local";
  printf("Local3 : %s\n", str_l);
  printf("Global3 : %s\n", str_g);
  pthread_exit (0);
}

void main (int argc, char** argv) {


  pthread_t th;
  void* ret;

sleep(1);
  if (pthread_create(&th, NULL, my_thread_process, NULL) < 0) {
    fprintf (stderr, "pthread_create error for thread th\n");
    exit (1);
  }
  if (pthread_create(&th, NULL, my_thread_process, NULL) < 0) {
    fprintf (stderr, "pthread_create error for thread th\n");
    exit (1);
  }

  if (pthread_create(&th, NULL, my_thread_process3, NULL) < 0) {
    fprintf (stderr, "pthread_create error for thread th3\n");
    exit (1);
  }


  (void)pthread_join(th, &ret);
}
