Results 1 to 3 of 3
  1. #1
    Dosta is offline Member
    Join Date
    Jul 2010
    Posts
    1
    Rep Power
    0

    Default Running multiple threads on multiple CPU cores?

    Can someone tell me if there is a way to run java code (with multiple threads) on multiple processors. Like an option flag for JVM upon running the code?

    I've got 30-100 threads and all of them are allocated to a single core and the main idea was to spread them around so the calculation would go faster, but everything i tried so far didn't work.

    It would be great if JVM supported an option (flag option) for running such code, but every flag i tried didn't work...

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,431
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Dosta View Post
    Can someone tell me if there is a way to run java code (with multiple threads) on multiple processors. Like an option flag for JVM upon running the code?

    I've got 30-100 threads and all of them are allocated to a single core and the main idea was to spread them around so the calculation would go faster, but everything i tried so far didn't work.

    It would be great if JVM supported an option (flag option) for running such code, but every flag i tried didn't work...
    That is not a job for the JVM; it is the OS that allocates a core for a thread, the JVM is just a program. If you're running this on an MS Windows machine you can try to set the 'affinity' for the JVM, i.e. tell the scheduler (task manager) what CPUs (cores) the JVM is allowed to use.

    kind regards,

    Jos

  3. #3
    Horcrux7 is offline Member
    Join Date
    Sep 2010
    Posts
    33
    Rep Power
    0

    Default

    On which OS do you run your Java program? The most JVM use multiple core by default. It can't disable.

    I think your problem is that all threads are block on one synchronized. The result is that only one thread can be run.

Similar Threads

  1. Question about running Multiple Threads
    By ferdzz in forum New To Java
    Replies: 2
    Last Post: 06-29-2010, 01:19 PM
  2. How to band threads with cup cores?
    By young in forum Threads and Synchronization
    Replies: 4
    Last Post: 04-06-2010, 01:39 PM
  3. One socket and multiple threads
    By DC200 in forum Networking
    Replies: 1
    Last Post: 12-30-2009, 06:32 AM
  4. multiple threads access the same method.
    By bhanu in forum New To Java
    Replies: 3
    Last Post: 02-16-2009, 06:54 AM
  5. running multiple server
    By amitnayak1 in forum Advanced Java
    Replies: 3
    Last Post: 06-05-2008, 04:14 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
  •