+ 1

How many threads use simultaneously in java?

1st Nov 2017, 5:31 PM
Sunil Kohli
Sunil Kohli - avatar
2 Respostas
+ 5
That'll depend upon your computer's hardware and ability to maintain the threads. So to answer your question, however many your computer can handle. To put it into perspective, I've seen thousands of threads running simultaneously.
1st Nov 2017, 6:01 PM
AgentSmith
+ 4
When profiling servers (other lang) I'd open around 40,000 network sockets and give them threads. File handles run out after this (I think just a socket thing), so I went poking at Java to see if there were similar restrictions + follow @Netkos Ent's trail. https://dzone.com/articles/java-what-limit-number-threads A chart there indicates "bitness" (32/64 bit) and stack size ("ThreadStackSize=") limit the max threads...showing a range ~11K to ~32K. Unless you're stress-testing, @Netkos's "thousands" seems good enough because...16GB virtual memory for 32K threads? Ouch.
1st Nov 2017, 7:04 PM
Kirk Schafer
Kirk Schafer - avatar