Java very limited on max number of threads?

后端 未结 6 1592
萌比男神i
萌比男神i 2021-02-08 07:53

We have a small text box with 512Mb of ram. We wanted to see how many threads we can create in Java in this box. To our surprise, we can\'t create many. Essentially the minimum

6条回答
  •  后悔当初
    2021-02-08 08:28

    Try setting the maximum memory allowed -Xmx to a lower value and see whether the thread count can be increased. In a project at work I could allocate around 2,5k threads with -Xmx512m and about 4k threads with -Xmx96m.

    The bigger your heap the smaller your thread stack space (at least to my experience).

提交回复
热议问题