Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想以纳秒为单位计算两个事件之间经过的时间。为此,我可以使用这里System.nanoTime()提到的。问题是这两个事件发生在不同的线程中。
System.nanoTime()
由于nanoTime()不返回绝对时间戳,而是只能用于计算时间差,我想知道我在两个不同线程上得到的值是否与两个事件之间经过的物理时间一致。
nanoTime()
应该是,但由于内核或硬件有问题,答案可能是 no,至少在某些环境中是这样。