Function current_id

fn current_id() -> ThreadId

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);