L1VM - thread in main function

I now found a way to run threads inside the main function. This may be useful. Here we go:

// hello-thread-new.l1com
// Brackets - Hello world! threads in main function
// This is an exammple how to launch threads using the new compiler opcode "loadl".
#include <intr.l1h>
(main func)
    (set int64 1 zero 0)
    (set int64 1 one 1)
    (set int64 1 f 0)
    (set int64 1 cpu 0)
    (set string s hello_onestr "Hello world! thr 1")
    (set string s hello_twostr "Hello world! thr 2")
    (set int64 1 t1_l 0)
    (set int64 1 t2_l 0)

    // set thread labels
    (:ta t1_l loadl)
    (:tb t2_l loadl)

    // run the two threads
    get_cpu (cpu)
    (((cpu zero ==) f =) f if)
        thread (t1_l)
        thread (t2_l)
        (:do_wait jmp)

    print_s (hello_onestr)
    threadexit (zero)

    print_s (hello_twostr)
    threadexit (zero)

    exit (zero)

The program is also on my L1VM GitHub repo!

Here is the output:

$ l1vm prog/hello-thread-new -q
current CPU: 0, starts new CPU: 1
current CPU: 0, starts new CPU: 2
Hello world! thr 1
thread EXIT
Hello world! thr 2
thread EXIT