Function std::thread::spawn [] [src]

pub fn spawn<F, T>(f: F) -> JoinHandle<T> where F: FnOnce() -> T, F: Send + 'static, T: Send + 'static

Spawns a new thread, returning a JoinHandle`JoinHandle` for it.

The join handle will implicitly detach the child thread upon being dropped. In this case, the child thread may outlive the parent (unless the parent thread is the main thread; the whole process is terminated when the main thread finishes.) Additionally, the join handle provides a join`joinmethod that can be used to join the child thread. If the child thread panics,` method that can be used to join the child thread. If the child thread panics, join`joinwill return an` will return an Err`Errcontaining the argument given to` containing the argument given to panic`panic`.

Panics

Panics if the OS fails to create a thread; use Builder::spawn`Builder::spawn` to recover from such errors.