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
return value
This method returns the maximum number of processors available to the virtual machine;
Abnormal
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