105_threading2.patch 499 B

12345678910111213
  1. --- exercises/105_threading2.zig 2024-03-23 16:35:14.754540802 +0100
  2. +++ answers/105_threading2.zig 2024-03-23 16:38:00.577539733 +0100
  3. @@ -81,8 +81,8 @@
  4. defer handle1.join();
  5. // Second thread to calculate the minus numbers.
  6. - ???
  7. -
  8. + const handle2 = try std.Thread.spawn(.{}, thread_pi, .{ &pi_minus, 3, count });
  9. + defer handle2.join();
  10. }
  11. // Here we add up the results.
  12. std.debug.print("PI ≈ {d:.8}\n", .{4 + pi_plus - pi_minus});