public final class Threads extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
sleepFor(long sleepTime,
TimeUnit unit)
Equivalent of
Thread.sleep(long) with arguments and semantics of timed wait methods in classes from java.util.concurrent (like Semaphore.tryAcquire(long, TimeUnit),
Lock.tryLock(long, TimeUnit), etc.): if the sleepTime argument is negative or
zero, the method returns immediately. |
public static void sleepFor(long sleepTime,
TimeUnit unit)
throws InterruptedException
Thread.sleep(long) with arguments and semantics of timed wait methods in classes from java.util.concurrent (like Semaphore.tryAcquire(long, TimeUnit),
Lock.tryLock(long, TimeUnit), etc.): if the sleepTime argument is negative or
zero, the method returns immediately. Thread.sleep(long), on the contrary, throws an IllegalArgumentException if
the argument is negative and attempts to unschedule the thread if the argument is zero.InterruptedException - if the current thread is interrupted when this method is called or during sleeping.Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.