Explore Courses Blog Tutorials Interview Questions
0 votes
in Java by (10.2k points)

How many threads can a Java VM support? Does this vary by vendor? by operating system? other factors?

1 Answer

0 votes
by (46k points)

This depends on the CPU you're using, on the OS, on what other processes are doing, on what Java release you're using, and other factors. I've seen a Windows server have > 6500 Threads before bringing the machine down. Most of the threads were not doing anything, of course. Once the machine hit about 6500 Threads (in Java), the whole machine started to have difficulties and become weak.

My experience shows that Java (recent versions) can happily consume as many Threads as the machine itself can host without problems.

Of course, you have to have sufficient RAM and you have to have started Java with enough memory to do everything that the Threads are doing and to have a stack for each thread. Any machine with a modern CPU (most recent couple generations of AMD or Intel) and with 1 - 2 Gig of retention (depending on OS) can easily hold a JVM with thousands of Threads.

If you need a more precise answer than this, your safest bet is to profile.

Related questions

Browse Categories