Maximum number of threads than can run concurrently in java on a CPU

前端 未结 4 1984
萌比男神i
萌比男神i 2020-12-30 09:02

Please I got confused about something. What I know is that the maximum number of threads that can run concurrently on a normal CPU of a modern computer ranges from 8 to 16 t

4条回答
  •  时光说笑
    2020-12-30 09:59

    There is hardware and software concurrency. The 8 to 16 threads refers to the hardware you have - that is one or more CPUs with hardware to execute 8 to 16 threads parallel to each other. The thousands of threads refers to the number of software threads, the scheduler will have to swap them out so every software thread gets its time slice to run on the hardware.

    To get the number of hardware threads you can try Runtime.availableProcessors().

提交回复
热议问题