I want to fork/run two threads, where each is supposed to do some work (say call a REST API). But, I want them to stop/interrupt when reaching some timeout threshold, if not returned yet.
Currently, I am using tokio::spawn()
but still unable to produce such a code. Although any keyword would be appreciated, but a code snippet would be more valuable.
Just use the select! macro. For more details, refer to the official Rust Async Book.