For diagnostics and debugging it can often be useful to get an ID that is different for every thread. The standard library does not expose a way to do that, hence this crate.
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.
Thread-ID is licensed under the Apache 2.0 license. 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. If you want to use Thread-ID in your GPLv2-licensed software, you can add an exception to your copyright notice.