Unable to create native thread in Normal Condition

I am trying to analyze the "OOM unable to create native thread" error that occurred in our application. I wrote a sample program which has to creates 5000 threads and monitored it using JConsole.

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

/*

* ThreadJvmMemory.java

*

* Created on June 1, 2007, 9:49 AM

*

* To change this template, choose Tools | Template Manager

* and open the template in the editor.

*/

/**

*

* @author Administrator

*/

public class ThreadJvmMemory extends Thread{

/** Creates a new instance of ThreadJvmMemory */

BufferedReader in = null;

public ThreadJvmMemory() {

}

public static void main(String args[]){

ThreadJvmMemory dummy = new ThreadJvmMemory();

dummy.waitTillEnter();

for(int i=0;i<5000;i++){

if(i%1000==0){

System.out.println(i);

dummy.waitTillEnter();

}

ThreadJvmMemory dummy1 = new ThreadJvmMemory();

dummy1.start();

}

}

public void run(){

//System.out.println("Here");

Object dummyObject = new Object();

try {

in = new BufferedReader(new InputStreamReader(System.in));

in.readLine();

} catch (IOException ex) {

ex.printStackTrace();

}

System.out.println("Came out of the thread");

}

public void waitTillEnter(){

try {

if(in==null)

in = new BufferedReader(new InputStreamReader(System.in));

in.readLine();

} catch (IOException ex) {

ex.printStackTrace();

}

}

}

I started the program using the following command line option..

"c:\Program Files\Java\jdk1.5.0_09\bin\java.exe" -Dcom.sun.management.jmxremote.port=9979 -Xmx512m -Xminf0.1 -Xmaxf0.1 -XX:MaxPermSize=256m -XX:PermSize=256m -XX:+<GCTYPE> -XX:+PrintGCDetails

where GCType will be UseTrainGC or UseSerialGC or UseParallelGC or

What i observe in all the cases, there are no more than 1000 threads getting created . After completion of 1000 threads garbage collector keeps running and no more threads get created. Since i have configured heapsize to be 512m, PermGenSpace to be 256 and default value for process sapece is 2gb, JVM would be able to create only 1000 threads as per the formula "NoOfThreads = Process space - (Heap + permGen+some for VM initialization)/Stack Size" (correct me if i am wrong). But why i am not getting OutOfMemoryError while creating native thread. Moreover i can observer non-heap (Perm Gen) space keep growing overtime. But there is enough space in all other spaces.So my doubts are

1. Actually when we will get OOM error saying unable to create Native thread.To be more specific when which space occupied i will get this error.

2. Is there any way to configure process space. IMO No ? Confirm ?

3. Does any one tried using a a tool that analyzes verboseGC output of SUN JVM. If so can you give any pointer. I have read through GCPortal, but i havent fully deployed it.

Java version is 1.5.0

OS Windows 2k3

Snippet of GC Output

[GC [DefNew: 5208K->38K(5824K), 0.0072564 secs] 32049K->26879K(34636K), 0.0080451 secs]

[GC [DefNew: 5222K->24K(5824K), 0.0070320 secs] 32063K->26868K(34636K), 0.0078097 secs]

[GC [DefNew: 5208K->39K(5824K), 0.0082161 secs] 32052K->26883K(34636K), 0.0090173 secs]

[GC [DefNew: 5223K->27K(5824K), 0.0080766 secs] 32067K->26874K(34636K), 0.0089273 secs]

[GC [DefNew: 5211K->39K(5824K), 0.0071186 secs] 32058K->26886K(34636K), 0.0078970 secs]

[GC [DefNew: 5223K->25K(5824K), 0.0070952 secs] 32070K->26875K(34636K), 0.0078766 secs]

[GC [DefNew: 5209K->21K(5824K), 0.0069871 secs] 32059K->26872K(34636K), 0.0077657 secs]

[3904 byte] By [veechanda] at [2007-11-15]