Struct std::thread::Builder [] [src]

pub struct Builder {
    // some fields omitted
}

Thread configuration. Provides detailed control over the properties and behavior of new threads.

Methods

impl Builder

fn new() -> Builder

Generates the base configuration for spawning a thread, from which configuration methods can be chained.

fn name(self, name: String) -> Builder

Names the thread-to-be. Currently the name is used for identification only in panic messages.

fn stack_size(self, size: usize) -> Builder

Sets the size of the stack for the new thread.

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

Spawns a new thread, and returns a join handle for it.

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). The join handle can be used to block on termination of the child thread, including recovering its panics.

Errors

Unlike the spawn free function, this method yields an io::Result to capture any failure to create the thread at the OS level.