@@ -27,19 +27,18 @@ fn main() {
2727
2828- Threads are all daemon threads, the main thread does not wait for them.
2929- Thread panics are independent of each other.
30- - Panics can carry a payload, which can be unpacked with ` downcast_ref ` .
30+ - Panics can carry a payload, which can be unpacked with
31+ [ ` Any::downcast_ref ` ] .
3132
3233<details >
3334
34- - Rust thread APIs look not too different from e.g. C++ ones.
35-
3635- Run the example.
3736 - 5ms timing is loose enough that main and spawned threads stay mostly in
3837 lockstep.
3938 - Notice that the program ends before the spawned thread reaches 10!
40- - This is because main ends the program and spawned threads do not make it
39+ - This is because ` main ` ends the program and spawned threads do not make it
4140 persist.
42- - Compare to pthreads/C++ std::thread/ boost::thread if desired.
41+ - Compare to ` pthreads ` /C++ ` std::thread ` / ` boost::thread ` if desired.
4342
4443- How do we wait around for the spawned thread to complete?
4544- [ ` thread::spawn ` ] returns a ` JoinHandle ` . Look at the docs.
@@ -69,9 +68,10 @@ fn main() {
6968 - Main kills child threads when it returns, but another function would just
7069 return and leave them running.
7170 - That would be stack use-after-return, which violates memory safety!
72- - How do we avoid this? see next slide.
71+ - How do we avoid this? See next slide.
7372
7473[ `Any` ] : https://doc.rust-lang.org/std/any/index.html
74+ [ `Any::downcast_ref` ] : https://doc.rust-lang.org/std/any/trait.Any.html#method.downcast_ref
7575[ `thread::spawn` ] : https://doc.rust-lang.org/std/thread/fn.spawn.html
7676[ `.join()` ] : https://doc.rust-lang.org/std/thread/struct.JoinHandle.html#method.join
7777
0 commit comments