[plt-scheme] Mred, exiting, and deamond threads

From: Guillaume Marceau (gmarceau at cs.brown.edu)
Date: Thu Jan 29 19:44:49 EST 2004

What is the rule that gouvern when mred exits, with respect to threads?

This program exits:

  (module test mzscheme
    (thread (lambda () (let loop () (display "hello\n") (sleep 1) (loop)))))


But this one doesn't:

  (module test mzscheme
    (thread (lambda () (let loop () (display "grettings\n") (sleep 1) (loop))))
    (thread-suspend (current-thread)))


Neither does this one:

  (module test mzscheme
    (require (lib "class.ss")
             (lib "mred.ss" "mred"))

    (define frame (instantiate frame% () (label "GUI") (height 150) (width 200)))
    (send frame show #t)

    (instantiate message% () (label "g'evening" frame))

    (thread (lambda () (let loop () (display "g'evening\n") (sleep 1) (loop)))))


Also, if I combine the two, gui widjets break:

  (module test mzscheme
    (require (lib "class.ss")
             (lib "mred.ss" "mred"))

    (define frame (instantiate frame% () (label "GUI") (height 150) (width 200)))
    (send frame show #t)

    (instantiate message% () (label "welcome" frame))

    (thread (lambda () (let loop () (display "welcome\n") (sleep 1) (loop))))
    (thread-suspend (current-thread)))

After the call to thread-suspend, the gui no longer refreshes.




-- 
"The thing I remember most about America is that it's silly.
 That can be quite a relief at times."  -- Thom Yorke, Radiohead

- Guillaume


Posted on the users mailing list.