104_threading.patch 724 B

1234567891011121314151617
  1. --- exercises/104_threading.zig 2024-04-10 19:12:29.878856370 +0200
  2. +++ answers/104_threading.zig 2024-04-10 19:11:22.304265713 +0200
  3. @@ -97,12 +97,12 @@
  4. defer handle.join();
  5. // Second thread
  6. - const handle2 = try std.Thread.spawn(.{}, thread_function, .{-4}); // that can't be right?
  7. + const handle2 = try std.Thread.spawn(.{}, thread_function, .{2});
  8. defer handle2.join();
  9. // Third thread
  10. const handle3 = try std.Thread.spawn(.{}, thread_function, .{3});
  11. - defer ??? // <-- something is missing
  12. + defer handle3.join();
  13. // After the threads have been started,
  14. // they run in parallel and we can still do some work in between.