title: How many threads can a Java VM support in Linux?
body: <p>I wrote Thread pool class referring  <a href="http://www.informit.com/articles/article.aspx?p=30483&amp;seqNum=5" rel="nofollow">http://www.informit.com/articles/article.aspx?p=30483&amp;seqNum=5</a></p>
  
  <p>Environment: Windows7 4 cp</p>
  
  <p>Executed my program with 70,000 Thread in Windows 7, under JDK 1.5  it went through successfully. Not used vm arguments. </p>
  
  <p>The same Code i tried to execute with 5,000 Thread in Linux enterprise edition which is under Virtual Box with 4GB base memory. with vm arguments -xms512m -xmx1024m. It executes till 2156 threads and throws an exception </p>
  
  <p>Exception in thread "main" java.lang.OutOfMemoryError: unable to create new native thread
          at java.lang.Thread.start0(Native Method)
          at java.lang.Thread.start(Thread.java:597)
          at testthreadpool.ThreadPool.(ThreadPool.java:38)
          at testthreadpool.TestThreadPool.main(TestThreadPool.java:16)</p>
  
  <p>But the same code run perfectly in windows7. </p>
  
  <p>May i know why this error occurs. Does  this java code need 1GB memory to run Just 5,000 Threads?...</p>
  
  <p>My actual requirement is to hold a ThreadPool with 10,000 Workthread.</p>