public class ThreadUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
handleUncaughtException(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 handleUncaughtException(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.public static void sleep(long millis)
Thread.sleep(long) to avoid the necessity of catching the InterruptedException.millis - the execution delay, in milliseconds.