hi,
Would like to know what is maximum number of threads which can be created in a single virtual machine.
Information says that there is effect of settings of Xmx Xms and Xss on the number of threads created.
I see no difference when I execute attached code with different values.
Instead I observed that increasing values of -Xmx actually reduces the number of threads created, whereas Xss values do not have any effect.
I am using Windows 2000 , jdk1.5 , 1.5GB ram.
Any reasons for such behaviour.
public class ThreadTest {
public static void main(
String[] pArgs) throws Exception {
try {
while (true) {
new TestThread().start();
}
} catch ( OutOfMemoryError e ) {
System.out.println(TestThread.CREATE_COUNT );
System.exit(-1);
}
}
static class TestThread extends
Thread {
private static int CREATE_COUNT = 0;
public TestThread() {
CREATE_COUNT++;
}
public void run() {
try {
sleep(Integer.MAX_VALUE );
} catch (InterruptedException e) {
System.out.println("Interrupted");
}
}
}
}