Parag Shah
Posts: 24
Nickname: parags
Registered: Mar, 2003
|
|
Can a JDK 1.4 thread sleep in nanosecond time?
|
Posted: Mar 23, 2007 10:18 AM
|
|
|
Advertisement
|
JDK 1.4 did not have any methods to report time in ns, but can it's internal counter manage nanosecond time?
For example will the following code put the thread to sleep for 50 ns or will it be a minumum of 1 ms?
Thread.sleep(0, 50);
The following code gives me an output of 15 ms on my computer.
long t1 = System.currentTimeMillis();
for(int i=0; i<8;i++) {
Thread.sleep(0, 500000);
}
long t2 = System.currentTimeMillis();
System.out.println("Time for sleeping 8 time * 500000 ns: " + (t2-t1));
This seems to suggest that the thread is capable of sleeping in nanosecond time.
Can anyone shed some light on the matter.
Thanks Parag
|
|