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

void *thread0();
void *thread1();

int x,y;

int main(int argc, char *argv[]) {
  pthread_t thread[2];
  int i = 0;

  x = 0;
  y = 0;

  pthread_create(&thread[0], NULL, thread0, NULL);
  pthread_create(&thread[1], NULL, thread1, NULL);

  pthread_join(thread[0],NULL);
  pthread_join(thread[1],NULL);

  printf("\n");
}

void *thread0() {
  int r0;
  sleep(1);
  x = 1;
  r0 = y;
  printf("A: %d ", r0);
}

void *thread1() {
  int r1;
  sleep(1);
  y = 1;
  r1 = x;
  printf("B: %d ", r1);
}
