Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Runtime.getRuntime().availableProcessors()

I am trying to check the performance of a program. I refer this post get OS-level system information. When Runtime.availableProcessors() executes, I get an answer of 4. I read availableProcessors() but it tells that this method returns number of processors

  1. Can anyone explain what is mean by number of processors ?
  2. Why am getting 4 as result ?

I am using Windows 7 core i5 4gp.

like image 347
Amith Avatar asked Aug 09 '12 06:08

Amith


People also ask

What is runtime getRuntime ()?

getRuntime. public static Runtime getRuntime() Returns the runtime object associated with the current Java application. Most of the methods of class Runtime are instance methods and must be invoked with respect to the current runtime object.

What does runtime getRuntime <UNK> availableProcessors return?

Runtime. getRuntime. availableProcessors to get the number of cores per node.

What is runtime library in Java?

The Java Runtime Environment, or JRE, is a software layer that runs on top of a computer's operating system software and provides the class libraries and other resources that a specific Java program needs to run.

How can you get the target parallelism level in Java?

The getParallelism() method of ForkJoinPool class is used to get the parallelism level of the common Pool. It returns an integer value representing the parallelism level.


1 Answers

As you've read, availableProcessors() is a method that returns the number of processors available to the JVM. 4 means the number of processors currently available for JVM.

These lines return the number of logical cores on Windows and in other operating systems.

On a computer with a quad-core Core i7 supporting Hyper-Threading, it will return 8.

On a computer with a quad-core Q6700, this method will return 4.

like image 109
AlphaMale Avatar answered Oct 10 '22 06:10

AlphaMale