diff options
| author | jaystile <46078028+jaystile@users.noreply.github.com> | 2021-12-23 06:19:39 -0800 |
|---|---|---|
| committer | mokou <mokou@fastmail.com> | 2022-07-15 11:58:26 +0200 |
| commit | b4f52cb937e9f2b90913402964ae014240705a5f (patch) | |
| tree | ad66a2b1df8d47a417446269dfaa66dec96af7d1 /info.toml | |
| parent | 20024d40c5e121202f283b420d7da1deecf4ebc0 (diff) | |
feat: Adding threads1.rs with a focus on JoinHandles and waiting for
spawned threads to finish. Moved the original threads1.rs to threads2.rs
with the focus on the Mutex and modifying shared data. #892
Diffstat (limited to 'info.toml')
| -rw-r--r-- | info.toml | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -878,6 +878,22 @@ name = "threads1" path = "exercises/threads/threads1.rs" mode = "compile" hint = """ +`JoinHandle` is a struct that is returned from a spawned thread: +https://doc.rust-lang.org/std/thread/fn.spawn.html + +A challenge with multi-threaded applications is that the main thread can +finish before the spawned threads are completed. +https://doc.rust-lang.org/book/ch16-01-threads.html#waiting-for-all-threads-to-finish-using-join-handle + +Collect the JoinHandles and wait for them to finish. +https://doc.rust-lang.org/std/thread/struct.JoinHandle.html +""" + +[[exercises]] +name = "threads2" +path = "exercises/threads/threads2.rs" +mode = "compile" +hint = """ `Arc` is an Atomic Reference Counted pointer that allows safe, shared access 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 @@ -898,14 +914,6 @@ 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. -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 :) - -Please open an issue if you're still running into a problem that -these hints are not helping you with, or if you've looked at the sample -answers and don't understand why they work and yours doesn't. - 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 :)""" |
