6 stable releases

3.3.0 Mar 23, 2018
3.2.0 Jun 26, 2017
3.1.0 May 13, 2017
3.0.0 Oct 29, 2016
1.0.0 Mar 13, 2016

#50 in Concurrency

Download history 24111/week @ 2019-11-08 25233/week @ 2019-11-15 25192/week @ 2019-11-22 22112/week @ 2019-11-29 25516/week @ 2019-12-06 24150/week @ 2019-12-13 15468/week @ 2019-12-20 11898/week @ 2019-12-27 18915/week @ 2020-01-03 24787/week @ 2020-01-10 21966/week @ 2020-01-17 24133/week @ 2020-01-24 21741/week @ 2020-01-31 19264/week @ 2020-02-07 17046/week @ 2020-02-14

100,640 downloads per month
Used in 794 crates (15 directly)

MIT/Apache

8KB

Thread-ID

Get a unique ID for the current thread in Rust.

Build Status Build Status Crates.io version Documentation

For diagnostics and debugging it can often be useful to get an ID that is different for every thread. Until Rust 1.14, the standard library did not expose a way to do that, hence this crate.

Example

use std::thread;
use thread_id;

thread::spawn(move || {
    println!("spawned thread has id {}", thread_id::get());
});

println!("main thread has id {}", thread_id::get());

This will print two different numbers.

License

Thread-ID is licensed under either the Apache 2.0 license, or the MIT license, at your option. It may be used in free software as well as closed-source applications, both for commercial and non-commercial use under the conditions given in the license.

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache 2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~47KB