4 releases (2 breaking)

0.3.1 Jun 25, 2025
0.3.0 Jun 12, 2025
0.2.0 Jun 12, 2025
0.1.0 Jun 12, 2025

#117 in Windows APIs

Download history 28/week @ 2025-10-08 62/week @ 2025-10-15 81/week @ 2025-10-22 24/week @ 2025-10-29 47/week @ 2025-11-05 45/week @ 2025-11-12 36/week @ 2025-11-19 56/week @ 2025-11-26 85/week @ 2025-12-03 318/week @ 2025-12-10 88/week @ 2025-12-17 105/week @ 2025-12-24 233/week @ 2025-12-31 97/week @ 2026-01-07 134/week @ 2026-01-14 81/week @ 2026-01-21

549 downloads per month

MIT license

13KB
116 lines

thread-count

This is a fork of thread-amount, since that crate is archived and no longer works.

Crate Version Documentation License

Get the number of threads in the current process

Example Usage

Cargo.toml

[dependencies]
thread-count = "0.1"

The code:

use thread_count::thread_count;

use std::thread;

fn main() {
    let count = thread_count();

    thread::spawn(move || {
        assert_eq!(count.map(NonZeroUsize::get), Some(1))
    });
}

Difference between num-threads

This crate has windows support and reads the /proc/[PID]/status file in -unix systems.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Tomio

💻 📖 💡 🚇 🚧

This project follows the all-contributors specification. Contributions of any kind welcome!

License

Licensed under the MIT license (LICENSE or http://opensource.org/licenses/MIT)

Dependencies

~0–35MB
~460K SLoC