public final class ThreadUtil
extends java.lang.Object
| Constructor and Description |
|---|
ThreadUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
runWithTimeout(java.util.concurrent.Callable<T> callable,
long timeout)
Runs a Task with a specific timeout
|
static void |
runWithTimeout(java.lang.Runnable runnable,
long timeout)
Runs a Task with a specific timeout
|
static void |
sleep(long delay)
Let the thread sleeps
|
static void |
sleep(long delay,
boolean ignore)
Let the thread sleeps
|
public static void sleep(long delay)
delay - time to sleep in millisecondspublic static void sleep(long delay,
boolean ignore)
ignore - should we ignore InterruptedException's that happen while sleepingdelay - time to sleep in millisecondspublic static void runWithTimeout(java.lang.Runnable runnable,
long timeout)
throws java.lang.Exception
runnable - the runnable to runtimeout - the timeout in millisecondsjava.lang.Exception - if the timeout is reached or a exception happens in the runnablepublic static <T> T runWithTimeout(java.util.concurrent.Callable<T> callable,
long timeout)
throws java.lang.Exception
callable - the runnable to runtimeout - the timeout in millisecondsjava.lang.Exception - if the timeout is reached or a exception happens in the runnable