1

Maximum number of threads in my linux system is 93946. I got this value from cat /proc/sys/kernel/threads-max. But when I create around 32768 threads I got error

cannot create new native threads
  • How can I create maximum number of threads(around 93946)?

  • If it is not possible to create maximum number of threads (93946), how can I find maximum number of threads allowed to run?

Mathieu
  • 8,840
  • 7
  • 32
  • 45
John.D
  • 21
  • 1
  • 4
  • Are you trying to create 93946 threads in one only process? – Mathieu Feb 29 '16 at 10:01
  • At the risk of being unhelpful, I'd say that anything that needs tens of thousands of threads that's not running on some monstrous massively multiprocessor system is probably doing something very wrong indeed. That said, this doesn't seem to be an unreasonable question in itself ;) – Rook Feb 29 '16 at 10:01
  • My goal is to find maximum number of threads ,thats why I run a demo program which create infinitive number of threads.In real environment I have multiple processes. – John.D Feb 29 '16 at 10:12

2 Answers2

3

You can find max thread with command:

sysctl -a| grep kernel.threads-max

Edit the /etc/sysctl.conf file and add new value

kernel.threads-max = 93946

Make change effective with sysctl -p

jijinp
  • 2,592
  • 1
  • 13
  • 15
0

please check out /proc/sys/kernel/pid_max. Since threads have their own pid, this value limits the maximum number of threads too.