# Struct std::thread::JoinHandle 1.0.0 [−] [src]

    pub struct JoinHandle<T>(_);

An owned permission to join on a thread (block on its termination).

A `JoinHandle` detaches the child thread when it is dropped.

Due to platform restrictions, it is not possible to `Clone` this handle: the ability to join a child thread is a uniquely-owned permission.

This `struct` is created by the `thread::spawn` function and the `thread::Builder::spawn` method.

# Examples

Creation from `thread::spawn`:

fn main() { use std::thread; let join_handle: thread::JoinHandle<_> = thread::spawn(|| { // some work here }); }

    use std::thread;

    let join_handle: thread::JoinHandle<_> = thread::spawn(|| {
        // some work here
    });

Creation from `thread::Builder::spawn`:

fn main() { use std::thread; let builder = thread::Builder::new(); let join_handle: thread::JoinHandle<_> = builder.spawn(|| { // some work here }).unwrap(); }

    use std::thread;

    let builder = thread::Builder::new();

    let join_handle: thread::JoinHandle<_> = builder.spawn(|| {
        // some work here
    }).unwrap();

## Methods

### `impl<T> JoinHandle<T>`
[src]

#### `fn thread(&self) -> &Thread`

Extracts a handle to the underlying thread

#### `fn join(self) -> Result<T>`

Waits for the associated thread to finish.

If the child thread panics, `Err` is returned with the parameter given to `panic`.

## Trait Implementations

### `impl<T> JoinHandleExt for JoinHandle<T>`
1.9.0
[src]

#### `fn as_pthread_t(&self) -> RawPthread`

Extracts the raw pthread_t without taking ownership

#### `fn into_pthread_t(self) -> RawPthread`

Consumes the thread, returning the raw pthread_t Read more

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)