List of usage examples for java.util.concurrent TimeUnit sleep
public void sleep(long timeout) throws InterruptedException
From source file:Main.java
public static final void sleep(TimeUnit tu, long timeout) { try {/*from ww w . ja v a 2 s .co m*/ tu.sleep(timeout); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:Main.java
public static void sleep(TimeUnit timeUnit, long duration) { try {/* w w w . j av a2 s. c om*/ timeUnit.sleep(duration); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } }
From source file:Main.java
/** * Sleep and cached InterruptedException. * /* ww w. j ava2 s. c om*/ * @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; } }
From source file:org.apache.servicecomb.it.ITUtils.java
public static void forceWait(TimeUnit timeUnit, long timeout) { try {/*from www .jav a 2 s . com*/ timeUnit.sleep(timeout); } catch (InterruptedException e) { // eat the exception } }
From source file:com.github.restdriver.clientdriver.integration.VerifyWithinTest.java
private static void schnooze(long interval, TimeUnit unit) { try {//from www . j a v a2 s . c o m unit.sleep(interval); } catch (InterruptedException e) { throw new RuntimeException(e); } }
From source file:com.twitter.distributedlog.service.DistributedLogServer.java
static void closeServer(Pair<DistributedLogServiceImpl, Server> pair, long gracefulShutdownPeriod, TimeUnit timeUnit) { if (null != pair.getLeft()) { pair.getLeft().shutdown();/*w w w. j av a 2 s . c o m*/ if (gracefulShutdownPeriod > 0) { try { timeUnit.sleep(gracefulShutdownPeriod); } catch (InterruptedException e) { logger.info("Interrupted on waiting service shutting down state propagated to all clients : ", e); } } } if (null != pair.getRight()) { logger.info("Closing dl thrift server."); pair.getRight().close(); logger.info("Closed dl thrift server."); } }
From source file:com.meltmedia.dropwizard.etcd.json.EtcdWatchServiceIT.java
public static Thread startWaitThread(long timeout, TimeUnit unit) { Thread waitThread = new Thread(() -> { try {//from w w w .jav a2 s. c om unit.sleep(timeout); } catch (Exception e) { // oh well! } }); waitThread.start(); return waitThread; }
From source file:com.github.marsbits.restfbmessenger.sample.EchoCallbackHandler.java
private void sleep(TimeUnit timeUnit, long duration) { try {/*from w w w . j a v a 2 s . com*/ timeUnit.sleep(duration); } catch (InterruptedException ignore) { } }
From source file:org.apache.hadoop.hbase.client.TestAsyncClusterAdminApi2.java
private void trySleep(long timeout, TimeUnit unit) { try {/*from w ww . j a va 2s . co m*/ unit.sleep(timeout); } catch (InterruptedException e) { } }
From source file:nz.co.senanque.locking.simple.SimpleLock.java
public boolean tryLock(long arg0, TimeUnit arg1) throws InterruptedException { if (!tryLock()) { arg1.sleep(arg0); return tryLock(); }// ww w .j av a2 s .c om return true; }