0 Replies Latest reply: Jul 31, 2012 12:05 AM by 952917 RSS

    Multithreading with java

    952917
      I am not sure if this question belongs here. Let me know if there is a better place for it.

      Today I learned how to write a multithreaded program in java.
      I created a class which implemented Runnable its run method in my main function.
      Everything worked exactly as I had intended. What I am curious about it the CPU usage.
      When the program was running I opened up task manager and the CPU usage was at 50%. This makes sense as I am running two threads on a quad core CPU (Half the cores working).
      The confusing part is that the load was distributed over all four cores. I expected to see two cores at 100% and two at ~0%.

      Clearly I don't understand how my processor runs multiple threads. Can someone explain to me why its not running on just two cores, each at 100%.
      Also if the threads don't correspond to the cores then where does the now seemingly arbitrary 50% come from?