How many threads are concurrently started by the Java virtual function

Source: Internet
Author: User

To create a new class, import the following test code:

1  Public classTestnativeoutofmemoryerror {2      Public Static voidMain (string[] args) {3 4          for(inti = 0;; i++) {5System.out.println ("i =" +i);6             NewThread (NewHoldthread ()). Start ();7         }8     }9 Ten } One  A classHoldthreadextendsThread { -Countdownlatch CDL =NewCountdownlatch (1); -  the      PublicHoldthread () { -          This. Setdaemon (true); -     } -  +      Public voidrun () { -         Try { + cdl.await (); A}Catch(interruptedexception e) { at         } -     } -}

Running the results on my development environment is as follows:

1 ...... 2 i = 39353newnative  thread4at    Java.lang.Thread.start0 (Native Method)5at     Java.lang.Thread.start (thread.java:714)  6at     Com.study.thinking.in.java.concurrent.TestNativeOutOfMemoryError.main ( TESTNATIVEOUTOFMEMORYERROR.JAVA:15)

The results of each run are not exactly the same, but the big difference is not bad.

Several parameters that affect the result:

1. Physical memory using 64-bit OS can allocate larger memory to virtual machines
2. Jvmmemory reduce this parameter can increase the number of concurrent threads, non-multiple relationships -xms1024m-xmx1024m can not be more than-xms512m-xmx512m one-fold thread
3. Threadstacksize reduces the stack size of a single thread, in the valid range, is a multiple relationship

More Information reference: http://sesame.iteye.com/blog/622670

How many threads are concurrently started by the Java virtual function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.