Next: , Up: Threading



11.1 Threading basics

     (make-thread (lambda () (write-line "Hello, world")))

— Structure: sb-thread:thread

Class precedence list: thread, structure-object, t

Thread type. Do not rely on threads being structs as it may change in future versions.

— Variable: sb-thread:*current-thread*

Bound in each thread to the thread itself.

— Function: sb-thread:make-thread function &key name

Create a new thread of name that runs function. When the function returns the thread exits.

— Function: sb-thread:thread-alive-p thread

Check if thread is running.

— Function: sb-thread:list-all-threads

Return a list of the live threads.

— Condition: sb-thread:interrupt-thread-error

Class precedence list: interrupt-thread-error, error, serious-condition, condition, t

Interrupting thread failed.

— Function: sb-thread:interrupt-thread-error-thread condition

The thread that was not interrupted.

— Function: sb-thread:interrupt-thread thread function

Interrupt the live thread and make it run function. A moderate degree of care is expected for use of interrupt-thread, due to its nature: if you interrupt a thread that was holding important locks then do something that turns out to need those locks, you probably won't like the effect.

— Function: sb-thread:terminate-thread thread

Terminate the thread identified by thread, by causing it to run sb-ext:quit - the usual cleanup forms will be evaluated