# Function std::thread::available_concurrency[−][src]

    pub fn available_concurrency() -> Result<NonZeroUsize>

🔬 This is a nightly-only experimental API. (`available_concurrency` #74479)

Returns the number of hardware threads available to the program.

This value should be considered only a hint.

# Platform-specific behavior

If interpreted as the number of actual hardware threads, it may undercount on Windows systems with more than 64 hardware threads. If interpreted as the available concurrency for that process, it may overcount on Windows systems when limited by a process wide affinity mask or job object limitations, and it may overcount on Linux systems when limited by a process wide affinity mask or affected by cgroups limits.

# Errors

This function will return an error in the following situations, but is not limited to just these cases:

- If the number of hardware threads is not known for the target platform.
- The process lacks permissions to view the number of hardware threads available.

# Examples

    #![feature(available_concurrency)]
    use std::thread;

    let count = thread::available_concurrency().map(|n| n.get()).unwrap_or(1);

Run