1
Fork 0
hare-playground/backend/cmd/threads/main.ha

18 lines
377 B
Hare
Raw Normal View History

2024-05-28 10:23:52 +00:00
use types::c;
use fmt;
2024-05-28 10:40:52 +00:00
use thread;
2024-05-28 10:23:52 +00:00
2024-05-28 10:49:26 +00:00
fn thread_start(data: nullable *opaque) void = {
let arg = data: *u32;
fmt::printfln("hello from another thread. you sent: {}", *arg)!;
2024-05-28 10:23:52 +00:00
};
export fn main() void = {
fmt::println("starting a thread")!;
2024-05-28 10:49:26 +00:00
let tid = thread::spawn(&thread_start, &42)!;
2024-05-28 10:23:52 +00:00
fmt::println("joining")!;
2024-05-28 10:40:52 +00:00
thread::join(tid)!;
fmt::println("joined. good bye.")!;
2024-05-28 10:23:52 +00:00
};