Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Runtime.getRuntime().availableProcessors()) and threads

807589Sep 7 2006 — edited Jul 16 2008
Hi

Im using java to find out how many cpu cores a machine have.

i use this code in my program:

Runtime.getRuntime().availableProcessors());

when running on my machine(with 1 cpu core) in linux i get out 2.
when running in windows i get 1, which is correct. why do i get wrong answer in linux?
is there some other way to find out this, that work both in linux and windows?

question 2:

when starting several threads on a machine with multiple cpu cores. do java use both cores, or could it happend that all threads run on one core?

if someone have links on this topic. please post them.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 13 2008
Added on Sep 7 2006
1 comment
69 views