Starting and stopping threads
Factor handbook > The language > Co-operative threads

Next:Yielding and suspending threads


Spawning new threads:
spawn ( quot name -- thread )

spawn-server ( quot name -- thread )


Creating and spawning a thread can be factored out into two separate steps:
<thread> ( quot name -- thread )

(spawn) ( thread -- )


Threads stop either when the quotation given to spawn returns, or when the following word is called:
stop ( -- * )


If the image is saved and started again, all runnable threads are stopped. Vocabularies wishing to have a background thread always running should use add-startup-hook.