Sir...
iam doing file searcher in hard disk.
i have to scan the hard disk...
if i scan the comp when it is loaded...system performance will be
degraded..
so i want to know wheather cpu is idle or not..?
if it is idle..i can use that time ...with causing inconvience to
user...
I think u Got my Point Sir...
ThankU Sir...
Roedy Green - 05 Mar 2006 15:21 GMT
>so i want to know wheather cpu is idle or not..?
you could detect that by creating a very low priority thread that did
something inane like compute pi. You check in on it after a second
to see how much it has accomplished. If a lot, then the machine is
idle.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Alun Harford - 05 Mar 2006 16:21 GMT
> Sir...
> iam doing file searcher in hard disk.
> i have to scan the hard disk...
> if i scan the comp when it is loaded...system performance will be
> degraded..
> so i want to know wheather cpu is idle or not..?
No you don't - you just want to schedule the thread with minimum priority.
If the JVM is any good, Java threads are mapped to OS threads, and it'll get
run with minimum priority by the OS.
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
Alun Harford
Dimitri Maziuk - 05 Mar 2006 19:58 GMT
master007 sez:
> Sir...
> iam doing file searcher in hard disk.
> i have to scan the hard disk...
> if i scan the comp when it is loaded...system performance will be
> degraded..
> so i want to know wheather cpu is idle or not..?
You can't: it's like opening the box except the cat is dead
100% of the time.
The code for checking must be executed by the cpu, so when
the check runs cpu will always be busy -- running the check.
HTH,HAND
Dima

Signature
Surely there is a polite way to say FOAD. -- Shmuel Metz
"Go forth and multiply". -- Paul Martin
Oliver Wong - 06 Mar 2006 19:25 GMT
> Sir...
> iam doing file searcher in hard disk.
[quoted text clipped - 8 lines]
>
> ThankU Sir...
I made a post about this earlier. See
http://tinyurl.com/jvvad
(original URL is:
http://groups.google.ca/group/comp.lang.java.programmer/browse_frm/thread/3edac1
e4ce9a2ece/ceaa37335d33440e#ceaa37335d33440e
)
- Oliver