I really seek a logical explanation regarding the following. I have a timed task
static TimerTask timedTask = new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
System.out.println("timed task");
}
};
Timer timer = new Timer();
timer.schedule(timedTask, (long) logfile.getFileHash().get(1).getTimeStampInNano());
when i run that code, nothing shows up in the console, but wen I change it to:
Timer timer = new Timer();
timer.schedule(timedTask, (long) logfile.getFileHash().get(1).getTimeStampInMilli());
the console displays the message in the run()
method. It seems to me that the system could not manage to handle time in nanoseconds because they are faster than the system clock. But how it is possible while there is a method called System.nanoTime()
, which means the system should be able to recognize that a tasks starts at specific nano seconds.
The api documentation on System.nanoTime() says:
As such, the JVM might not be able to see difference in time that are smaller than 1 millisecond.