aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/exercises/104_threading.zig
diff options
context:
space:
mode:
authorChris Boesch <chrboesch@noreply.codeberg.org>2024-04-10 17:21:18 +0000
committerChris Boesch <chrboesch@noreply.codeberg.org>2024-04-10 17:21:18 +0000
commit3c9c55df8e08d154908c41977dfc5794f9e01786 (patch)
tree8e7e1d231d7415897158939b05b79f043ce7f166 /exercises/104_threading.zig
parent2122c477a04f54655f71f78217d845485254cfab (diff)
parent376a8396725d981db776d6e7f3e2196af4f106ef (diff)
Merge pull request 'Additional timer in thread start added' (#77) from I75 into main
Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/77
Diffstat (limited to 'exercises/104_threading.zig')
-rw-r--r--exercises/104_threading.zig5
1 files changed, 3 insertions, 2 deletions
diff --git a/exercises/104_threading.zig b/exercises/104_threading.zig
index 7865839..ac40b3c 100644
--- a/exercises/104_threading.zig
+++ b/exercises/104_threading.zig
@@ -106,7 +106,7 @@ pub fn main() !void {
// After the threads have been started,
// they run in parallel and we can still do some work in between.
- std.time.sleep((1) * std.time.ns_per_s);
+ std.time.sleep(1500 * std.time.ns_per_ms);
std.debug.print("Some weird stuff, after starting the threads.\n", .{});
}
// After we have left the closed area, we wait until
@@ -117,10 +117,11 @@ pub fn main() !void {
// This function is started with every thread that we set up.
// In our example, we pass the number of the thread as a parameter.
fn thread_function(num: usize) !void {
+ std.time.sleep(200 * num * std.time.ns_per_ms);
std.debug.print("thread {d}: {s}\n", .{ num, "started." });
// This timer simulates the work of the thread.
- const work_time = 2 * ((5 - num % 3) - 2);
+ const work_time = 3 * ((5 - num % 3) - 2);
std.time.sleep(work_time * std.time.ns_per_s);
std.debug.print("thread {d}: {s}\n", .{ num, "finished." });