public class ThreadUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static void |
handleUncaughtException(java.lang.Exception e)
Deprecated.
Use
handleUncaughtException(Throwable) instead. |
static void |
handleUncaughtException(java.lang.Throwable t)
Handles
Throwable (either an exception or an error) which has not been caught in a particular scope. |
static void |
sleep(long millis)
Delays the execution of the current thread.
|
public static void sleep(long millis)
Thread.sleep(long) to avoid the necessity of catching the InterruptedException.millis - the execution delay, in milliseconds.public static void handleUncaughtException(java.lang.Throwable t)
Throwable (either an exception or an error) which has not been caught in a particular scope. If
the UncaughtExceptionHandler of the current thread has been set, it
is used to handle the Throwable. If not set, the default UncaughtExceptionHandler is used instead. If not set either, the stack trace of the Throwable is
printed.
The following example shows how this method may be used:
try {
connectionListener.onDisconnected();
} catch (Throwable t) {
ThreadUtils.handleUncaughtException(t);
}
t - the Throwable to handle.@Deprecated public static void handleUncaughtException(java.lang.Exception e)
handleUncaughtException(Throwable) instead.Exception by delegating it to handleUncaughtException(Throwable) for
backward compatibility.e - the uncaught exception to handle