Java Duration Calculate sleep(Duration duration)

Here you can find the source of sleep(Duration duration)

Description

Wrapper around Thread.sleep() that throws RuntimeException if the thread is interrupted.

License

Open Source License

Parameter

Parameter Description
duration the length of time to sleep

Exception

Parameter Description
IllegalArgumentException if the value of duration is negative

Declaration

public static void sleep(Duration duration) 

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.time.Duration;

public class Main {
    /**//from   w  ww  .jav  a 2  s .  c o  m
     * Wrapper around Thread.sleep() that throws RuntimeException if the thread is interrupted. Only
     * use this method if you don't care to be notified of interruptions via InterruptedException.
     *
     * @param duration the length of time to sleep
     * @throws IllegalArgumentException if the value of {@code duration} is negative
     */
    public static void sleep(Duration duration) {
        try {
            Thread.sleep(duration.toMillis());
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. minutesToDuration(long minutes)
  2. multiply(Duration duration, double factor)
  3. runAfter(Duration duration, Runnable toRun)
  4. seconds(Duration duration)
  5. serializeDuration(Duration duration)
  6. sleep(final Duration duration)
  7. within( CompletableFuture future, Duration duration)