Is it the same sleep method as above? I tried using sleep( 0, 1 ) with Windows XP Pro where I am expecting a CPU usage at or near 100% but its going only at 2%. When I change to sleep( 0 , 0 ) the CPU usage is at 100%.
I am using JBuilder Enterprise and Foundation with JDK 1.5.
If its not possible to make the sleep method work properly, is there another way to do it in Java?
this is certainly not a beginner's question. It really belongs in the specialised multithreading forum...
Your understanding of how multithreading works seems to be fundamentally flawed. You cannot control the running of a thread, and certainly not to the precision allowed in theory by the nanosecond precision option.
While in theory it COULD give you nanosecond precision over the minimum time the thread will sleep (NEVER over the exact time) in reality computers cannot (yet) handle such precision and will round to the nearest several milliseconds (most will use a minimum block of 20 msecs or so). As 1 nanosecond rounded to the nearest millisecond (let alone 20 of them) is 0 your thread will be sent to sleep for a period of no time at all.
If somebody says you look familiar, tell them you are in porn. Or in these tiny ads: