Java runtime.availableprocessors () method

Source: Internet
Author: User

Java runtime.availableprocessors () method usage Example Tutorial.Describe

The Java.lang.Runtime.availableProcessors () method returns the number of processors available to the Java Virtual machine. This value may change in a specific virtual machine call. The number of processors available to the application is sensitive, so it is occasionally queried for this property and appropriately adjusted for its resource usage.

Statement

The following is the declaration java.lang.Runtime.availableProcessors () method

public int availableprocessors ()
Parameters
    • NA

return value

This method returns the maximum number of processors available to the virtual machine;

Abnormal
    • NA

Instance

The following example shows how to use the lang. Runtime.availableprocessors () method.

Package Com.yiibai;public class Runtimedemo {public   static void Main (string[] args) {            //print a normal message
   system.out.println ("Hello world!");            Check the number of processors available      System.out.println ("" +runtime.getruntime (). Availableprocessors ());}   }

Let's compile and run the above program, which will produce the following results:

Hello world!4

Java runtime.availableprocessors () method

Related Article

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.