current_id

Function current_id 

Source
pub fn current_id() -> ThreadId
🔬This is a nightly-only experimental API. (current_thread_id #147194)
Expand description

Gets the unique identifier of the thread which invokes it.

Calling this function may be more efficient than accessing the current thread id through the current thread handle. i.e. thread::current().id().

This function will always succeed, will always return the same value for one thread and is guaranteed not to call the global allocator.

§Examples

#![feature(current_thread_id)]

use std::thread;

let other_thread = thread::spawn(|| {
    thread::current_id()
});

let other_thread_id = other_thread.join().unwrap();
assert_ne!(thread::current_id(), other_thread_id);