Java tutorial
//package com.java2s; //License from project: Apache License import java.util.concurrent.TimeUnit; public class Main { /** * Sleep and cached InterruptedException. * * @param millis * @return true:normal end, false: Interrupted */ public final static boolean sleepAndCachedInterruptedException(long sleepFor, TimeUnit unit) { if (sleepFor <= 0) { return true; } try { unit.sleep(sleepFor); return true; } catch (InterruptedException e) { // omit return false; } } }