onelinerhub
onelinerhub copied to clipboard
"How to join a thread with a timeout in Rust?" is not valid Rust
- A link to the code with a problem: https://onelinerhub.com/rust/how-to-join-a-thread-with-a-timeout-in-rust
- Short explanation of the problem in the solution
The code explains, that
join_timeout
can be used to join a thread with a timeout. This is false, as can be seen in the linked docs: https://doc.rust-lang.org/std/thread/struct.Thread.html#method.join_timeout and additionally https://doc.rust-lang.org/std/thread/struct.JoinHandle.html A JoinHandle has no functionjoin_timeout
. - Proposal of changes (if any):
Remove the example.
Alternatively implement something using
is_finished
instead, to check if the thread has finished.