public class ThreadUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
handleUncaughtException(Exception e)
Handles an exception 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(Exception e)
UncaughtExceptionHandler of the current thread
has been set, it is
used to handle the exception. If not set, the default
UncaughtExceptionHandler
is used instead. If not set either, the stack trace of the exception is printed.
The following example shows how this method may be used:
try { connectionListener.onDisconnected(); } catch (Exception e) { ThreadUtils.handleUncaughtException(e); }
e
- the exception 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.