diff --git a/book-src/07-02-shared-data.md b/book-src/07-02-shared-data.md index 965e842..5c96680 100644 --- a/book-src/07-02-shared-data.md +++ b/book-src/07-02-shared-data.md @@ -5,6 +5,6 @@ When we want to mutate data shared between threads, [`Mutex`](**Mut**ually **ex* ```zig {{#include ../src/07-02.zig}} ``` -If we remove Mutex protection, the result will most like be less than 300. +If we remove Mutex protection, the result will most like be less than 30,000. [`Mutex`]: https://ziglang.org/documentation/0.11.0/std/#A;std:Thread.Mutex diff --git a/src/07-02.zig b/src/07-02.zig index 652cd44..171b3b7 100644 --- a/src/07-02.zig +++ b/src/07-02.zig @@ -11,7 +11,7 @@ const SharedData = struct { self.mutex.lock(); defer self.mutex.unlock(); - for (0..100) |_| { + for (0..10000) |_| { self.value += increment; } } @@ -26,5 +26,5 @@ pub fn main() !void { const t2 = try Thread.spawn(.{}, SharedData.updateValue, .{ &shared_data, 2 }); defer t2.join(); } - try std.testing.expectEqual(shared_data.value, 300); + try std.testing.expectEqual(shared_data.value, 30_000); }