This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I don't get your question. What do you mean by threading? Could you provide some more details?
how does the allocation of threads/process take place across different CPUs
It's an implementation detail of the OS and the scheduler in question. Why do you need to know this? Also if at all you need to know this, you can do a complex testing on the system in question and after many days ( if not months ) of testing, you might get an idea. And then it may change as well. I hope you know that a process and a thread are two different things?
Joined: May 18, 2005
Chan thanks for quick and blunt answer. I should have put some more details in question, which i initially though would be obvious.
Let us say we have process p1 and p2. Each process can spawn threads t1....tn. Let us also assume i am working 2 processor environment with all other conditions(single & double processor) being same.
Let us say p1 is running on processor1 and p2 is running on processor2. p1 spawns threads t1,t2 and p2 spawn threads p3,p4.
question: When p1 spawns threads the does it run on a specific processor or can it switch the processors. I understand that it will depend on the environment(OS), but theoretically how does it work.
If i have to use concepts like synchronization, wait , sleep, join, notify etc. do i need to worry about the numbers of processors, or all the details are abstracted from user, and OS takes care of the stuff.
Naresh Chaurasia wrote:If i have to use concepts like synchronization, wait , sleep, join, notify etc. do i need to worry about the numbers of processors, or all the details are abstracted from user, and OS takes care of the stuff.
You'll notice that the Thread class in Java doesn't have any methods which refer to processors, multiple or otherwise, in any way. Which means that how the JVM and the Thread class and the operating system will deal with allocating threads to processors is completely hidden from you.
And if you look farther I expect you'll see that the tutorials about Thread don't mention anything about that issue either. Another hint that it's none of your business.