summaryrefslogtreecommitdiff
path: root/exercises/104_threading.zig
diff options
context:
space:
mode:
authorChris Boesch <chrboesch@noreply.codeberg.org>2025-11-01 15:52:40 +0100
committerChris Boesch <chrboesch@noreply.codeberg.org>2025-11-01 15:52:40 +0100
commit4c291f35d5470fc179f0aa524671f40ac60ba802 (patch)
treeff5ad49c1677165b1acbcc23637cba3956d20b68 /exercises/104_threading.zig
parentc45b9cd383b1463ca2e8cc93eb7ef38c4242d53a (diff)
parent147ff302ecbc534af01004a016fc2c091cba8af4 (diff)
Merge pull request 'fixed more changes due to new I/O API' (#316) from new_io_2 into main
Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/316
Diffstat (limited to 'exercises/104_threading.zig')
-rw-r--r--exercises/104_threading.zig6
1 files changed, 3 insertions, 3 deletions
diff --git a/exercises/104_threading.zig b/exercises/104_threading.zig
index 638769f..d0a640b 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.Thread.sleep(1500 * std.time.ns_per_ms);
+ std.posix.nanosleep(1, 0);
std.debug.print("Some weird stuff, after starting the threads.\n", .{});
}
// After we have left the closed area, we wait until
@@ -117,12 +117,12 @@ 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.Thread.sleep(200 * num * std.time.ns_per_ms);
+ std.posix.nanosleep(1 * num, 0);
std.debug.print("thread {d}: {s}\n", .{ num, "started." });
// This timer simulates the work of the thread.
const work_time = 3 * ((5 - num % 3) - 2);
- std.Thread.sleep(work_time * std.time.ns_per_s);
+ std.posix.nanosleep(work_time, 0);
std.debug.print("thread {d}: {s}\n", .{ num, "finished." });
}