If you want to increase or make maximum no of threads that a JVM runs on a single instance.
If so then:
The short answer is that it's limited by how much virtual address(VA) space you have, both address size (32/64) and swap.
The primary consumers of VA space are the java heap and associated C heap data structures, and thread stacks and (fairly small) per-thread C data structrure. A small amount of java heap space is consumed by Thread instances.
The default thread stack size is 512kb for the 32-bit jvm and 1mb for the 64-bit jvm on solaris sparc. You can gain more VA space for thread stacks by making the java heap smaller.
java -Xms2g -Xmx2g MAXTHREADS
On 32-bit sparc, you can typically get up to 4k or so threads before you run out of VA (maximum user VA is ~3.8gb). On 64-bit systems, the amount of swap is the effective limit: I know of an experiment that successfully created 160k threads.
Of course you're likely to run into severe performance problems long before you reach those levels as the thread administration code (so the code that governs which thread gets to run and for how long) starts to take up so much time that the actual application threads never get any time anymore.
The limitations are generally based on system resources - physical memory and CPU.
The number of threads that can run within a JVM process is generally limited by the address space for that process. Each thread requires a thread stack. The more threads you have, the more process address space you use. The more address space you use for thread stacks, the less you have for the Java heap. There is one more tricky you have when you have less heap; it triggers more GC occurance. This effects performance largely. So there's a bit of a balance that needs to be achieved. Generally, if you have a lot of active threads you will probably want a lot of heap space as well.
There is no default maximum. How manny threads you can create in a given heap size is OS-dependent; as people are trying to tell you, it depends on system resources. Many JVMs nowadays simply use the underlying OS's thread implementation, one Java thread per OS thread. Whatever limits the OS gives you, that's what you get.
Yes, there is a limit. After all there's a limit to the number of objects you can have in memory at any time. But you're likely to run into problems because of the available memory or CPU cycles in your computer before you run out of object space...
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop