const assert = std.debug.assert; const std = @import("std"); const spawn = std.Thread.spawn; threadlocal var x: i32 = 1234; test "thread local storage" { const thread1 = try spawn({}, testTls); defer thread1.wait(); const thread2 = try spawn({}, testTls); defer thread2.wait(); // Main thread testTls({}); } fn testTls(context: void) void { assert(x == 1234); x += 1; assert(x == 1235); }