Java VM - Eclipse using my kernels?

I have a JVM question about running my Java code. My friend has a 2.4 GHz or 2.5 GHz dual-core processor, while I have a 2 GHz quad-core processor. Now my question is: Does Java use all the cores or only one? My friend thought that Java uses 1 core, and therefore it will have a better run time because its core has a higher clock speed than mine.

+4
source share
2 answers

The JVM itself uses multiple threads, which are likely to use multiple cores (depending on the mood of the OS scheduler).

Your program uses as many threads as you ask to use. If your code is single-threaded, it will be sequential and will not be useful for your multi-core architecture (note that your single thread can use more than one core, but not at the same time).

+6
source

Java will benefit from several cores if the OS distributes threads over available processors. The JVM itself does nothing special to evenly distribute threads across multiple cores.

Typically, a Java application will try to schedule each active thread on a separate kernel. This includes garbage collector threads.

Take a look at the following links:

+4
source

All Articles