Eric Hanchrow <[EMAIL PROTECTED]> writes:

> Invoke the snippet with `guile -s snippet.scm'.  Note the total lack
> of output.

The process exits before it can produce any output.  "guile -s" exits
as soon as the main thread exits.  (The builtin simple-format is
probably fast enough to produce output anyway.)

Try this:

    (use-modules (ice-9 threads))
    (use-modules (ice-9 format))

    (define safe-format
      (let ((m (make-mutex)))
        (lambda args
          (with-mutex m
            (apply format args)))))

    (let ((ts (map (lambda (sym)
                     (make-thread
                      (lambda ()
                        (sleep (random 4))
                        (safe-format #t "Hey you: ~A~%" sym))))
                   (list 'bob 'sam 'huey 'luey 'duey))))
      (for-each join-thread ts))

It uses join-thread to wait for the threads to finish.

Note also that (ice-9 format) is not thread safe... (which I'm going
to fix soonish (when nothing preempts me)).

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Bug-guile mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-guile

Reply via email to