Skip to content

Commit 8107a0e

Browse files
authored
Update scoped-threads.md (#253)
Adding speaker notes explaining why scoped threads work and what borrowing rules apply.
1 parent 77a60d4 commit 8107a0e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/concurrency/scoped-threads.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,10 @@ fn main() {
3131
```
3232

3333
[1]: https://doc.rust-lang.org/std/thread/fn.scope.html
34+
35+
<details>
36+
37+
* The reason for that is that when the `thread::scope` function completes, all the threads are guaranteed to be joined, so they can return borrowed data.
38+
* Normal Rust borrowing rules apply: you can either borrow mutably by one thread, or immutably by any number of threads.
39+
40+
</details>

0 commit comments

Comments
 (0)