Results 1 to 3 of 3
Like Tree2Likes
  • 2 Post By JosAH

Thread: One process open multiple threads on multiple CPUs

  1. #1
    kfcnhl is offline Member
    Join Date
    Nov 2011
    Posts
    4
    Rep Power
    0

    Default One process open multiple threads on multiple CPUs

    I am using the code below to open up multiple threads (20+).
    However, it seems that all the threads are running on 1 CPU when I do have 4 cores(according to task manager).
    I am guessing there is a limitation on where my threads can be run.
    In other word, threads can only be open up on the CPU where the original process started.
    Obviously something have gone wrong some where.
    Anybody got some suggestions?
    Thanks a lot in advance :)

    Additional information on platform:
    I am using Eclipse to code.
    Have tried to run on both windows 7 and XP, none works.

    Runnable runnable = new XThread();
    Thread thread = new Thread(runnable);
    thread.start();

    public class XThread implements Runnable
    {
    public void run()
    {
    }
    }
    Last edited by kfcnhl; 12-09-2011 at 04:10 AM.

  2. #2
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: One process open multiple threads on multiple CPUs

    It could be that your particular JVM is using lightweight threads instead of OS-level threads. See if there's a JVM option to change it, try a different JVM, or switch to Linux.
    Get in the habit of using standard Java naming conventions!

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,436
    Blog Entries
    7
    Rep Power
    20

    Default Re: One process open multiple threads on multiple CPUs

    Quote Originally Posted by kjkrum View Post
    It could be that your particular JVM is using lightweight threads instead of OS-level threads.
    That would be so unlikely for recent versions of the JVM; more likely is that the 'affinity' of the JVM process is set to a single core. It can be changed with the task manager.

    kind regards,

    Jos
    DarrylBurke and kjkrum like this.
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. synchronization issue with multiple threads
    By harmeet in forum Threads and Synchronization
    Replies: 0
    Last Post: 05-01-2011, 04:01 AM
  2. Running multiple threads on multiple CPU cores?
    By Dosta in forum Threads and Synchronization
    Replies: 2
    Last Post: 09-19-2010, 03:48 PM
  3. One socket and multiple threads
    By DC200 in forum Networking
    Replies: 1
    Last Post: 12-30-2009, 06:32 AM
  4. Multiple Process Creation in EJB3.0
    By sankarguru in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 03-25-2009, 05:26 AM
  5. multiple threads access the same method.
    By bhanu in forum New To Java
    Replies: 3
    Last Post: 02-16-2009, 06:54 AM

Posting Permissions

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