Struct std::thread::ThreadId 1.19.0[−][src]
pub struct ThreadId(_);
Expand description
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);
RunImplementations
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
Auto Trait Implementations
impl RefUnwindSafe for ThreadId
impl UnwindSafe for ThreadId
Blanket Implementations
Mutably borrows from an owned value. Read more