Results 1 to 2 of 2
  1. #1
    aburnett397 is offline Member
    Join Date
    Feb 2011
    Rep Power

    Default Threads and cores


    Doing this simple experiment, I realized I don't have a clue as to how CPUs and/or threads work:

    public class Test {public static void main(String [] args) {while (true);}}

    On my i7 (4 cores + 4 virtual cores = 8 more or less), four cores start up when I run this thing (as reported by the windows 7 task manager) and run each at about a quarter of their capacity. Two things I can't figure out:

    1. I thought a thread ran on a single core. This one seems to be jumping about four of them.
    2. Why does the load of each core add up neatly to one? It seems like if the CPU wanted, it could run fully those four cores and speed up my single thread by a factor 4. And why not use all cores and make that 8?

    I guess that another possibility is that the thread is indeed on a single one of those cores, and that the activity on the other three is "induced" in some strange manner (running in debug, the other VM threads seem to be sleeping and do not seem responsible).

    If anyone could shed a little light on this subject I would be grateful.


  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    Default Re: Threads and cores

    I thought a thread ran on a single core
    I'd think it depends on the OS. It could be that any thread can run on any core. When the thread is paused, it goes into a queue while waiting to start executing again. When there is a core available for executing a thread, it goes to the queue and gets the next thread.

Similar Threads

  1. How to use two threads
    By rajan701v in forum Threads and Synchronization
    Replies: 2
    Last Post: 07-22-2011, 05:47 PM
  2. threads
    By brindha1688 in forum New To Java
    Replies: 3
    Last Post: 05-24-2011, 08:07 PM
  3. The right way of using threads
    By N00Bie in forum New To Java
    Replies: 9
    Last Post: 02-20-2011, 04:39 PM
  4. Running multiple threads on multiple CPU cores?
    By Dosta in forum Threads and Synchronization
    Replies: 2
    Last Post: 09-19-2010, 03:48 PM
  5. How to band threads with cup cores?
    By young in forum Threads and Synchronization
    Replies: 4
    Last Post: 04-06-2010, 01:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts