threads and pipes added by matijja on Sun Dec 8 18:49:01 2019

(import srfi-18
        (chicken io)
        (chicken port))

(define (read-pipe path)
  (print "Starting: " path)
  (flush-output)
  (with-input-from-file path
    (lambda ()
      (print "Thread " path " is ready.")
      (flush-output)
      (let rec ((line (read-line)))
        (unless (eof-object? line)
          (print path ": " line)
          (flush-output)
          (thread-yield!)
          (rec (read-line)))))))

(let ((t1 (thread-start! (lambda () (read-pipe "./pipe1"))))
      (t2 (thread-start! (lambda () (read-pipe "./pipe2")))))
  (thread-join! t1)
  (thread-join! t2))