简体   繁体   English

Java VM - Eclipse使用我的核心?

[英]Java VM - Eclipse using my cores?

I have this question about the JVM running my Java code. 我有关于运行我的Java代码的JVM这个问题。 My friend has a 2.4 or 2.5GHz dual core while I have a 2GHz quad core. 我的朋友有一个2.4或2.5GHz双核,而我有一个2GHz四核。 Now my question is: does Java use all the cores or just one? 现在我的问题是:Java是使用所有内核还是只使用一个内核? 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. 我的朋友认为Java使用1核心,因此他的运行时间会更长,因为他的核心时钟频率比我的高。

The JVM itself uses several threads, which will most likely use several cores (depending on the mood of the OS scheduler). JVM本身使用多个线程,这很可能会使用多个核心(取决于OS调度程序的情绪)。

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). 如果您的代码是单线程的,那么它将是顺序的,并且不会从您的多核架构中受益(但请注意,您的单个线程可能使用多个核心,但不能同时使用)。

Java will benefit from multiple cores, if the OS distribute threads over the available processors. 如果操作系统通过可用处理器分配线程,Java将受益于多个内核。 JVM itself do not do anything special to get its threads scheduled evenly across multiple cores. JVM本身并没有做任何特别的事情来让它的线程在多个核心上均匀地进行调度。

Generally, Java application will try to schedule every active thread on a separate core. 通常,Java应用程序将尝试在单独的核心上安排每个活动线程。 This includes the Garbage collector thread. 这包括垃圾收集器线程。

Take a look of following links : 看看以下链接:

  1. how-does-java-makes-use-of-multiple-cores 如何-不-java的让-使用-的-多核心

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM