Yes I am sure there is no such API. There have been some RFEs (Requests for Enhancement) on this matter and as far as I know, none is to be implemented anytime soon.
Considering Java is meant to be portable and could very well run on single processor machines just like multi-processor ones, the details about which CPU a Thread is assigned to is better left to the JVM and it's Scheduler.
> > But in C or C++, there is API to bind a thread to
> a
> > specific CPU. Are u sure there is no such kind API
> in
> > Java so far?
>
> So... use RMI and the C/C++ API to do the work for
> you then?
Er, JNI maybe?
> > In my program, I
> > need to assign thread to each CPU.
>
> That's rather unlikely. You may think you do, but
> you're almost certainly mistaken.
I think you're wrong. I added the CPU from my broken toaster (don't ask) to my computer to take advantage the processing multi-core enablement. But as you may imagine, it's quite slower than PC processor. So it's useful for me to be able to specify that I want certain threads not to be running on my toaster. Let's call these ButterThreads (don't get butter in your toaster!).
Is there no way in Java to ensure code run only in toaster? This possible in C++, C.
> Even though you're trying to re-use your toaster, the
> API still hasn't changed since my last reply.
I heard that there is new "curranty" API in the Tigers, Java 5 (or 1.5!!!!!) to use. This enable me do this? Is called curranty because there currants in hot cross buns, eccles cakes and soreen malt loaf? All uses in toasting I think, so maybe you get better knowledge of upto date APIs.