Package org.apache.druid.concurrent
Class Threads
java.lang.Object
org.apache.druid.concurrent.Threads
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidEquivalent ofThread.sleep(long)with arguments and semantics of timed wait methods in classes fromjava.util.concurrent(likeSemaphore.tryAcquire(long, TimeUnit),Lock.tryLock(long, TimeUnit), etc.): if the sleepTime argument is negative or zero, the method returns immediately.static AutoCloseablewithThreadName(String name) Temporarily renames the thread.
-
Constructor Details
-
Threads
public Threads()
-
-
Method Details
-
sleepFor
Equivalent ofThread.sleep(long)with arguments and semantics of timed wait methods in classes fromjava.util.concurrent(likeSemaphore.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.- Throws:
InterruptedException- if the current thread is interrupted when this method is called or during sleeping.
-
withThreadName
Temporarily renames the thread. Preferred usage should be via try-with-resources clauses.- Returns:
- a
AutoCloseableto rename the thread back to its original name.
-