[previous] [up] [next]     [contents] [index]
Next: Semaphores Up: Threads Previous: Threads

Thread Utilities

(current-thread) returns the thread descriptor for the currently executing thread.

(thread? v) returns #t if v is a thread descriptor, #f otherwise.

(sleep n) causes the current thread to sleep for at least n seconds. The n argument defaults to 0 (allowing other threads to execute when operating system threads are not used). The value of n can be non-integral to request a sleep duration to any precision, but the precision of the actual sleep time is unspecified.

(thread-running? thread) returns #t if thread has not terminated, #f otherwise.

(thread-wait thread) blocks execution of the current thread until thread has terminated. Note that (thread-wait (current-thread)) deadlocks the current thread, but a ``user'' break can end the deadlock (if breaking is enabled; see section 8.5).

(kill-thread thread) terminates the specified thread immediately. Terminating the main thread exits the application. If thread is already not running, kill-thread does nothing. Otherwise, if the current custodian (see section 9.5) does not manage thread (and none of its subordinates manages thread), the exn:misc:thread:kill exception is raised.

(break-thread thread) registers a ``user'' break with the specified thread. If breaking is disabled in thread, the break will be ignored until breaks are re-enabled (see section 8.5).

(thread-weight thread) returns the weight of the specified thread. A thread weight is an integer indicating how much work this thread can perform before another thread is swapped in. The default weight is 10000. The weight is only meaningful when operating system threads are not used to implement MzScheme threads.

(thread-weight thread weight) sets the weight of thread, where weight is an integer. The maximum weight is platform-dependent, and the exn:application:integer exception is raised if weight is too large.


[previous] [up] [next]     [contents] [index]
Next: Semaphores Up: Threads Previous: Threads

PLT