Function std::thread::current1.0.0[][src]

pub fn current() -> Thread
Expand description

获取调用它的线程的句柄。

Examples

使用 thread::current() 获取当前线程的句柄:

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