diff options
| author | Chris Boesch <chrboesch@noreply.codeberg.org> | 2026-06-26 16:41:49 +0200 |
|---|---|---|
| committer | Chris Boesch <chrboesch@noreply.codeberg.org> | 2026-06-26 16:41:49 +0200 |
| commit | d093f37e1e4c5aed4a4c8d4999001134aec251ca (patch) | |
| tree | 4a3ab21a8d3daad4f25543980e1933bc620dbcb5 | |
| parent | 12c8511412f45e79e40a7b5cb8a29039d8f40fa4 (diff) | |
| parent | fdf47e3b8c0b5b248cc1fbc071b3262f5cfa816a (diff) | |
Merge pull request 'Fix misleading comments' (#476) from it3x/fix-threads-comment into main
Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/476
| -rw-r--r-- | exercises/107_threading.zig | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/exercises/107_threading.zig b/exercises/107_threading.zig index 5072648..aaec6b1 100644 --- a/exercises/107_threading.zig +++ b/exercises/107_threading.zig @@ -75,10 +75,10 @@ pub fn main() !void { std.debug.print("Starting work...\n", .{}); // These curly braces are very important, they are necessary - // to enclose the area where the threads are called. - // Without these braces, the program would not wait for the - // end of the threads and they would continue to run beyond the - // end of the program. + // to enclose the area where the threads are called and joined. + // With these braces, the program will block and wait for all threads + // to finish right at the closing brace of this block, ensuring + // "Zig is cool!" is always printed last. { // Now we start the first thread, with the number as parameter const handle = try std.Thread.spawn(.{}, thread_function, .{1}); @@ -102,8 +102,7 @@ pub fn main() !void { try io.sleep(std.Io.Duration.fromMilliseconds(400), .awake); std.debug.print("Some weird stuff, after starting the threads.\n", .{}); } - // After we have left the closed area, we wait until - // the threads have run through, if this has not yet been the case. + // The threads are guaranteed to be finished by the time we reach here. std.debug.print("Zig is cool!\n", .{}); } |
