Java Threads not running concurrently in RC3

Discussion in 'Parallels Desktop for Mac' started by JMB8877, Feb 20, 2007.

  1. JMB8877

    JMB8877 Bit poster

    Messages:
    4
    I'm studying a course in Java programming at University. We use Borland JBuilder 4 as our IDE. I run JBuilder on Windows XP under Parallels RC3 on my MacBook Pro using a BootCamp installation.

    We've just started studying threads and concurrent programming. We wrote a very simple program to demonstrate the use of threaded applications. Running this program while booted into BootCamp shows that the program is running threaded, but if I then boot the same XP system in Parallels and run the same Java program the output shows that one thread runs first and then the other, not concurrent at all!

    I have to write a fairly complex fully threaded client/server program in Java for an exam next month and it looks like I'll have to use BootCamp instead of Parallels for that to make sure it all works. :(

    EDIT: Hmm, we're just written another program using threads and that one worked fine in Parallels, so maybe it was just some strange glitch!
     
    Last edited: Feb 20, 2007
  2. joem

    joem Forum Maven

    Messages:
    1,247
    Simultaneous execution of threads on a single processor machine is an illusion -- they don't run at the same time. Multiple threads just insure that if the program is properly written, blocking one thread won't automatically block another.

    The MBP is a dual core machine, so in bootcamp, threads really can run simultaneously because there are effectively two processors, while in Parallels, only one processor (core) is available for the VM.

    The threading mechanism in the guest is the responsibility of the guest OS and is not controlled by Parallels.
     
  3. JMB8877

    JMB8877 Bit poster

    Messages:
    4
    Yes, I'm aware of how threads work.

    The program was designed to show how threads function by running the same code twice, once using threads the other not; the output being different between the two. While in BootCamp the program functions correctly every time. In Parallels the output of the program shows the same output for both runs, so it looks like the code for the unthreaded part runs twice. Just because Parallels in only using one core shouldn't really affect the program in that way.

    Anyway, it still means that I'll have to use BootCamp for doing this part of the course...
     
  4. dkp

    dkp Forum Maven

    Messages:
    1,367
    I'd be interested in a side-by-side comparison with VMWare's Fusion which uses two CPU's in the VM (user option).
     

Share This Page