Spawn
The spawn keyword is used to create a new Cangjie thread. It accepts a lambda expression with no parameters, and the code within this lambda will execute concurrently in the new thread.
Cangjie uses an M:N threading model where Cangjie threads are lightweight user-space threads scheduled by underlying native threads, making them lighter than operating system threads. When the main thread ends, all unfinished new threads will also stop together.
The code on the right creates three threads: the main thread and two worker threads. Since thread execution order is indeterminate, you may see different output orders each time you run the program.
Note
A new thread may not have executed any code before the main thread ends, so the main thread needs to wait for child threads to complete.