# 1.19.0[−][src]Struct std::thread::ThreadId

    pub struct ThreadId(_);

A unique identifier for a running thread.

A `ThreadId` is an opaque object that has a unique value for each thread that creates one. `ThreadId`s are not guaranteed to correspond to a thread's system-designated identifier. A `ThreadId` can be retrieved from the `id` method on a `Thread`.

# Examples

    use std::thread;

    let other_thread = thread::spawn(|| {
        thread::current().id()
    });

    let other_thread_id = other_thread.join().unwrap();
    assert!(thread::current().id() != other_thread_id);

Run

## Methods

### `impl ThreadId`[src]

#### `pub fn as_u64(&self) -> u64`[src]

🔬 This is a nightly-only experimental API. (`thread_id_value` #67939)

This returns a numeric identifier for the thread identified by this `ThreadId`.

As noted in the documentation for the type itself, it is essentially an opaque ID, but is guaranteed to be unique for each thread. The returned value is entirely opaque -- only equality testing is stable. Note that it is not guaranteed which values new threads will return, and this may change across Rust versions.

## Trait Implementations

### `impl Clone for ThreadId`[src]

#### `fn clone(&self) -> ThreadId`[src]

Returns a copy of the value. Read more

#### `fn clone_from(&mut self, source: &Self)`1.0.0[src]

Performs copy-assignment from `source`. Read more

### `impl Copy for ThreadId`[src]

### `impl Debug for ThreadId`[src]

#### `fn fmt(&self, f: &mut Formatter) -> Result`[src]

Formats the value using the given formatter. Read more

### `impl Eq for ThreadId`[src]

### `impl Hash for ThreadId`[src]

#### `fn hash<__H: Hasher>(&self, state: &mut __H)`[src]

Feeds this value into the given [`Hasher`]. Read more

#### `fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,` 1.3.0[src]

Feeds a slice of this type into the given [`Hasher`]. Read more

### `impl PartialEq<ThreadId> for ThreadId`[src]

#### `fn eq(&self, other: &ThreadId) -> bool`[src]

This method tests for `self` and `other` values to be equal, and is used by `==`. Read more

#### `fn ne(&self, other: &ThreadId) -> bool`[src]

This method tests for `!=`.

### `impl StructuralEq for ThreadId`[src]

### `impl StructuralPartialEq for ThreadId`[src]

## Auto Trait Implementations

### `impl RefUnwindSafe for ThreadId`

### `impl Send for ThreadId`

### `impl Sync for ThreadId`

### `impl Unpin for ThreadId`

### `impl UnwindSafe for ThreadId`

## Blanket Implementations

### `impl<T> Any for T where
T: 'static + ?Sized,` [src]

#### `fn type_id(&self) -> TypeId`[src]

Gets the `TypeId` of `self`. Read more

### `impl<T> Borrow<T> for T where
T: ?Sized,` [src]

####
ⓘImportant traits for &'_ mut I

### Important traits for &'_ mut I

`impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, R: Read + ?Sized> Read for &'_ mut Rimpl<'_, W: Write + ?Sized> Write for &'_ mut W`
`fn borrow(&self) -> &T`[src]

Immutably borrows from an owned value. Read more

### `impl<T> BorrowMut<T> for T where
T: ?Sized,` [src]

####
ⓘImportant traits for &'_ mut I

### Important traits for &'_ mut I

`impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, R: Read + ?Sized> Read for &'_ mut Rimpl<'_, W: Write + ?Sized> Write for &'_ mut W`
`fn borrow_mut(&mut self) -> &mut T`[src]

Mutably borrows from an owned value. Read more

### `impl<T> From<T> for T`[src]

#### `fn from(t: T) -> T`[src]

Performs the conversion.

### `impl<T, U> Into<U> for T where
U: From<T>,` [src]

#### `fn into(self) -> U`[src]

Performs the conversion.

### `impl<T> ToOwned for T where
T: Clone,` [src]

#### `type Owned = T`

The resulting type after obtaining ownership.

#### `fn to_owned(&self) -> T`[src]

Creates owned data from borrowed data, usually by cloning. Read more

#### `fn clone_into(&self, target: &mut T)`[src]

🔬 This is a nightly-only experimental API. (`toowned_clone_into` #41263)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

### `impl<T, U> TryFrom<U> for T where
U: Into<T>,` [src]

#### `type Error = Infallible`

The type returned in the event of a conversion error.

#### `fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>`[src]

Performs the conversion.

### `impl<T, U> TryInto<U> for T where
U: TryFrom<T>,` [src]

#### `type Error = <U as TryFrom<T>>::Error`

The type returned in the event of a conversion error.

#### `fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>`[src]

Performs the conversion.