Here you can find the source of sleepFor(long period, TimeUnit timeUnit)
Parameter | Description |
---|---|
period | time period to sleep |
timeUnit | TimeUnit that specifies in which units the time period is measured |
public static void sleepFor(long period, TimeUnit timeUnit)
//package com.java2s; //License from project: Open Source License import java.util.concurrent.TimeUnit; public class Main { /**// www . j a v a 2s . com * This method is a convenience method for sleep that "swallows" {@link InterruptedException} and * has {@link TimeUnit} parameter in addition to time period so it makes it very convenient. So with * this method there is no need to convert the time into milliseconds. Just simply write * <br><br> * <p>{@code sleepFor(10, TimeUnit.SECONDS);}</p> * <br> No Exception catching needed * @param period time period to sleep * @param timeUnit {@link TimeUnit} that specifies in which units the time period is measured */ public static void sleepFor(long period, TimeUnit timeUnit) { try { timeUnit.sleep(period); } catch (InterruptedException ie) { } } }