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+
I have two questions
1)what is relation of stack and heap size in java?
2)On what factor does max no of thread depends in java?
 
     
    