What's the purpose of sleep(long millis, int nanos)?

前端 未结 3 1440
夕颜
夕颜 2020-12-10 01:16

In the JDK, it\'s implemented as:

public static void sleep(long millis, int nanos) 
throws InterruptedException {
if (millis < 0) {
        throw new Ille         


        
3条回答
  •  情歌与酒
    2020-12-10 01:46

    It looks like a future-proof addition, for when we all have petaflop laptops and we routinely specify delays in nanoseconds. Meanwhile if you specify a nanosecond delay, you get a millisecond delay.

    When hardware improves and the JVM follows, the app will not need to be rewritten.

提交回复
热议问题