rustlings icon indicating copy to clipboard operation
rustlings copied to clipboard

threads1.rs breakdown suggestion

Open jaystile opened this issue 4 years ago • 1 comments

I recently finished the rustlings course at version 4.6.0. I noted in the hint for threads1.rs looked like a cry for help: Ok, so, real talk, this was actually tricky for me to do too. And I could see a lot of different problems you might run into, so at this point I'm not sure which one you've hit :) I also had trouble implementing the exercise. I borrowed heavily from the last section of the book on threads. It involved adding the Mutex, moving the 'status.clone()' into the loop, and then unwrapping the mutex to check for if the number of threads has been completed. It was a lot of edits for the single exercise. It seemed odd to check the value to see if the threads had finished.

My recommendation, is to split threads1.rs into two exercises

  1. threads1.rs would focus on using the JoinHandle result from spawning 10 threads and waiting the threads to finish.
  2. threads2.rs starts with the result from threads1.rs. It then stubs out the Arc and hints for the Mutex implementation to change shared data. Ask for the final value held by the mutex at the end of the exercise.

jaystile avatar Dec 23 '21 13:12 jaystile

It seems that https://github.com/rust-lang/rustlings/commit/b4f52cb937e9f2b90913402964ae014240705a5f has fixed it. So this issue should be closed now?

YDX-2147483647 avatar Sep 11 '22 05:09 YDX-2147483647