thread [body ...]
Creates and returns a new thread, which will last until the body terminates.
|
>(thread (+ 1 2) (+ 3 4))
#<thread:...t/private/kw.rkt:592:14>
>(type (thread (+ 1 2)))
thread
|
new-thread procedure
Creates and returns a new thread, which will last until procedure terminates. This was called thread in arc0.
|
>(new-thread (fn () (+ 1 2)))
#<thread:...t/private/kw.rkt:592:14>
|
break-thread thread
Triggers a break exception on a thread.
|
>(let th (thread (sleep 2))
(break-thread th))
user break
|
kill-thread thread
Terminates the specified thread immediately.
|
>(let th (thread (sleep 100))
(kill-thread th)
(dead th))
t
|
sleep secs
Causes the current thread to sleep for at least the
specified time.
|
>(sleep 0.1)
nil
|
dead thread
Predicate to test if a thread has terminated.
|
>(let th (thread (sleep 1))
(prn (dead th)) (sleep 2) (prn (dead th)))
nil
t
t
|
Copyright 2008 Ken Shirriff.