How Many Threads Can a Java Vm Support

How many threads can a Java VM support?

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 around 6500 Threads (in Java), the whole machine started to have problems and become unstable.

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

Of course, you have to have enough 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 memory (depending on OS) can easily support a JVM with thousands of Threads.

If you need a more specific answer than this, your best bet is to profile.

Maximum number of threads in a JVM?

Writing a loop that creates new threads until it blows up is the definitive way to find out. You might well see performance degrade terribly before it actually dies.

I don't know if there's any configuration parameter or other built-in limit in the JVM off the top of my head. I've never run into a limit in practice. Of course sooner or later you will run out of memory, maybe some other resource.

I suspect that there is not a limit on number of threads per se, but rather on resources associated with a thread. That is, you might see that you can have 10,000 threads if all of them are running just one small class with a few bytes of data each, but the number drops rapidly when they each have an array of 10 million strings.

How many java threads can be created for a dual core processor

You can run 20 threads even on a single-core machine.
What happens is called time slicing.

http://en.wikipedia.org/wiki/Time_slice#Time_slice

It is a way for the processor to simulate multiple
processors executing multiple tasks as once.

How to determine max number of threads avialable in Java-VM?

The max number of threads for a JVM is generally somewhere in the thousands. If you're using multiple threads to optimize a computational algorithm you don't really want more than the number of processors in the system its run on. Use Runtime.getRuntime().availableProcessors() to find out.



Related Topics



Leave a reply



Submit