Here you can find the source of sleep(Duration duration)
Parameter | Description |
---|---|
duration | the length of time to sleep |
Parameter | Description |
---|---|
IllegalArgumentException | if the value of duration is negative |
public static void sleep(Duration duration)
//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); } } }