Note that there are some explanatory texts on larger screens.

plurals
  1. PODual-core CPU utilization w/ single Java thread running
    text
    copied!<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/1649402/would-a-multithreaded-java-application-exploit-a-multi-core-machine-very-well">Would a multithreaded Java application exploit a multi-core machine very well?</a> </p> </blockquote> <p>I have a plain and simple Java thread like this running on my dual-core machine (Windows XP 32bit enviroment)</p> <pre><code>public static void main(String[] strs) { long j = 0; for(long i = 0; i&lt;Long.MAX_VALUE; i++) j++; System.out.println(j); } </code></pre> <p>My expectation was that it would stick to a single CPU to fully exploit the high-speed cache(since in the loop we keep operating with local variable j, hence one CPU utiliaztion would be 100% and the other would be pretty much idle. To my suprise both of the CPUs are being utilized at around 40%~60% after the thread starts and the utilization of one CPU is slightly higher than the other.</p> <p>My question is that Is there any OS load-balancing mechanism that kicks in when out-of-balance has been detected? In my case is it possible that Windows OS found that one CPU is hitting nearly 100% and the other is almost idle so it reschedules the thread to another CPU periodically?</p> <p><img src="https://i.stack.imgur.com/rit1D.jpg" alt="enter image description here"></p> <p><strong>#EDIT1</strong> I've found a possible explanation: <a href="http://siber.cankaya.edu.tr/ozdogan/OperatingSystems/ceng328/node130.html" rel="nofollow noreferrer">http://siber.cankaya.edu.tr/ozdogan/OperatingSystems/ceng328/node130.html</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload