Search code examples
javaeclipseprocessor

Java VM - Eclipse using my cores?


I have this question about the JVM running my Java code. My friend has a 2.4 or 2.5GHz dual core while I have a 2GHz quad core. Now my question is: does Java use all the cores or just one? My friend thought Java used 1 core and so he would have the better running time because his core has a higher clock rate than mine.


Solution

  • The JVM itself uses several threads, which will most likely use several cores (depending on the mood of the OS scheduler).

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