current — 현재 스레드 핸들 얻기

current — 현재 스레드 핸들 얻기

current는 그것을 호출하는 스레드에 대한 핸들을 반환해요.

출처: Rust 공식 문서

본문

pub fn current() -> Thread

예시

use std::thread;

let handler = thread::Builder::new()
    .name("named thread".into())
    .spawn(|| {
        let handle = thread::current();
        assert_eq!(handle.name(), Some("named thread"));
    })
    .unwrap();

handler.join().unwrap();

더 알아보기 (Learn more)