From 842e341895690aa8d59aab42d6294994ef99d10f Mon Sep 17 00:00:00 2001 From: mo8it Date: Wed, 27 Mar 2024 21:24:36 +0100 Subject: threads2: simplify threads2 --- info.toml | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'info.toml') diff --git a/info.toml b/info.toml index b1cd64c..36629b3 100644 --- a/info.toml +++ b/info.toml @@ -1136,25 +1136,17 @@ to **immutable** data. But we want to *change* the number of `jobs_completed` so we'll need to also use another type that will only allow one thread to mutate the data at a time. Take a look at this section of the book: https://doc.rust-lang.org/book/ch16-03-shared-state.html#atomic-reference-counting-with-arct -and keep reading if you'd like more hints :) -Do you now have an `Arc` `Mutex` `JobStatus` at the beginning of main? Like: +Keep reading if you'd like more hints :) + +Do you now have an `Arc>` at the beginning of `main`? Like: ``` let status = Arc::new(Mutex::new(JobStatus { jobs_completed: 0 })); ``` -Similar to the code in the example in the book that happens after the text -that says 'Sharing a Mutex Between Multiple Threads'. If not, give that a -try! If you do and would like more hints, keep reading!! - -Make sure neither of your threads are holding onto the lock of the mutex -while they are sleeping, since this will prevent the other thread from -being allowed to get the lock. Locks are automatically released when -they go out of scope. - -If you've learned from the sample solutions, I encourage you to come -back to this exercise and try it again in a few days to reinforce -what you've learned :)""" +Similar to the code in the following example in the book: +https://doc.rust-lang.org/book/ch16-03-shared-state.html#sharing-a-mutext-between-multiple-threads +""" [[exercises]] name = "threads3" -- cgit v1.2.3