14

I am seeing conflicting information about the maximum number of threads that a Rust program can spawn; some suggest arbitrary numbers like "32", sometimes a multiple of the number of cores the CPU has.

Steve Klabnik
  • 14,521
  • 4
  • 58
  • 99

1 Answers1

18

The threads provided by the Rust standard library are "OS threads", that is, they use the facilities of your operating system.

Therefore, a Rust program has no limit imposed by Rust itself, but rather, this limit would result from whatever your OS lets you do. You'd have to know the OS to know the true answer, which would be different for a given OS. For example, see this question: "Maximum number of threads per process in Linux?"

Steve Klabnik
  • 14,521
  • 4
  • 58
  • 99