Back to course

Concurrency: Threads

Full Course: Zig Programming From Zero to Hero

Multi-threading

Zig provides a standard way to spawn and manage OS threads.

zig fn work(id: u32) void { std.debug.print("Thread {d} is working\n", .{id}); }

pub fn main() !void { const thread = try std.Thread.spawn(.{}, work, .{1}); thread.join(); }