This discussion is archived
3 Replies Latest reply: Dec 30, 2012 11:19 PM by EJP RSS

maximum thread in java

982041 Newbie
Currently Being Moderated
I have created a program to check max no of thread in java

public class Test extends Thread {
static int count;

public static void main (String [] args){
for(;;){
count++;
System.out.println(count);
new Test().start();
}
}



@Override
public void run() {
try {
Thread.sleep(100000000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

First iteration -Xmx1024m ,max thread = 2011 > Second iteration -Xmx512m ,max thread = 3350 > third iteration -Xmx2m ,max thread = 5112

I have also tried with setting -Xss1m ,max thread = 1011, then I have set -Xss256k max thread 4900+

Can anyone suggest me
1)what is relation of stack and heap size in java?
2)On what factor does max no of thread depends in java?

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points