let affiche s =
  Printf.printf "Debut de affiche %s\n" s; flush stdout;
  for i = 0 to 3 do
    Printf.printf "%s%d\n" s i; flush stdout;
    Thread.delay (Random.float 1.0)
  done;
  Printf.printf "Fin de affiche  %s\n" s
;;

Printf.printf "Création des threads\n"; flush stdout;;
let ta = Thread.create affiche "A";;
let tb = Thread.create affiche "B";;
Printf.printf "J'attends A ... \n"; flush stdout;;
Thread.join ta;;
Printf.printf "J'attends B ... \n"; flush stdout;;
Thread.join tb;;
Printf.printf "Fin du programme\n"; flush stdout;;