[plt-scheme] Idiom for suspending the top level thread
At Tue, 13 Jun 2006 03:54:04 -0700 (PDT), Noel Welsh wrote:
> What is the preferred idiom for suspending the top level
> thread to stop a program exiting?
My favorite is
(sync (make-semaphore))
or, in MrEd,
(yield (make-semaphore))
> (let loop () (loop)) ;; busy wait
Definitely not. :)
> (thread-suspend (current-thread))
This is probably not a good idea, since suspending the main thread
prevents handling break signals. If the other threads finish without
resuming the main thread, MzScheme will complain with "unbreakable
deadlock" and immediately exit.
> (thread-wait (current-thread))
This one is fine.
Matthew