public class ThreadUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
ThreadUtils.BlockingOperation
Utility interface to be used with executeUninterruptibly() to wait for blocking operations
to complete without getting interrupted..
|
static class |
ThreadUtils.ThreadChecker
Utility class to be used for checking that a method is called on the correct thread.
|
Constructor and Description |
---|
ThreadUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
awaitUninterruptibly(java.util.concurrent.CountDownLatch latch) |
static boolean |
awaitUninterruptibly(java.util.concurrent.CountDownLatch barrier,
long timeoutMs) |
static void |
checkIsOnMainThread()
Throws exception if called from other than main thread.
|
static void |
executeUninterruptibly(ThreadUtils.BlockingOperation operation)
Utility method to make sure a blocking operation is executed to completion without getting
interrupted.
|
static <V> V |
invokeAtFrontUninterruptibly(android.os.Handler handler,
java.util.concurrent.Callable<V> callable)
Post |callable| to |handler| and wait for the result.
|
static void |
invokeAtFrontUninterruptibly(android.os.Handler handler,
java.lang.Runnable runner)
Post |runner| to |handler|, at the front, and wait for completion.
|
static void |
joinUninterruptibly(java.lang.Thread thread) |
static boolean |
joinUninterruptibly(java.lang.Thread thread,
long timeoutMs) |
public static void checkIsOnMainThread()
public static void executeUninterruptibly(ThreadUtils.BlockingOperation operation)
public static boolean joinUninterruptibly(java.lang.Thread thread, long timeoutMs)
public static void joinUninterruptibly(java.lang.Thread thread)
public static void awaitUninterruptibly(java.util.concurrent.CountDownLatch latch)
public static boolean awaitUninterruptibly(java.util.concurrent.CountDownLatch barrier, long timeoutMs)
public static <V> V invokeAtFrontUninterruptibly(android.os.Handler handler, java.util.concurrent.Callable<V> callable)
public static void invokeAtFrontUninterruptibly(android.os.Handler handler, java.lang.Runnable runner)