Originally posted by Wagner Danda:
In a computer with 2 processors, when I create 4 threads, 2 will be on Running state and 2 on Ready?
Thanks in advance,
Wagner Danda
I don't think so. This really comes down to the implementation of your operating system. The JVM (which your application runs on) is really just one of many threads being executed by your operating system. For example, if you're running Windows, a number of threads are bring run at any one time. Which ones are running and which ones are ready is entirely up to the operating system. Since the JVM is just one
thread that's being implemented, it will only run on one processor at a time (and even then for it's timeslice). That process will then switch back and forth between your four threads, so they'll probably never be executing on both processors at once.
I guess this really boils down to how your operating system handles multiple processes, but I'd develop your code as if there was only one processor inside your box. Forget that there are two of them because only the operating system itself can really take advantage of that.
This area isn't really my forte, so I'm kinda guessing here. Perhaps someone else can give a more enlightened answer, but this is what I think, anyway.
Corey