Saturday, 10 June 2017

Java Tutorial: Java Runtime class (How to get available Processors) ~ foundjava


Click here to watch in Youtube : 
https://www.youtube.com/watch?v=V-Ph3vkW6io&list=UUhwKlOVR041tngjerWxVccw

RuntimeDemo.java
public class RuntimeDemo
{
    public static void main(String[] args) 
    {
        /*
         * Returns the runtime object associated with the
         * current Java application.
         */
        Runtime runtime = Runtime.getRuntime();

        /*
         * Returns: the maximum number of processors
         * available to the virtual machine; never smaller
         * than one
         */
        int availableProcessors = runtime.availableProcessors();
        System.out.println("availableProcessors = "+availableProcessors);
    }

}
Output
availableProcessors = 4
Click the below link to download the code:

CLICK HERE

No comments:

Post a Comment