public class Threading extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Threading.UserThread |
Modifier and Type | Field and Description |
---|---|
static CycleDetectingLockFactory |
factory |
static Executor |
SAME_THREAD
A dummy executor that just invokes the runnable immediately.
|
static ListeningExecutorService |
THREAD_POOL
A caching thread pool that creates daemon threads, which won't keep the JVM alive waiting for more work.
|
static Thread.UncaughtExceptionHandler |
uncaughtExceptionHandler
An exception handler that will be invoked for any exceptions that occur in the user thread, and
any unhandled exceptions that are caught whilst the framework is processing network traffic or doing other
background tasks.
|
static Executor |
USER_THREAD
An executor with one thread that is intended for running event listeners on.
|
Constructor and Description |
---|
Threading() |
Modifier and Type | Method and Description |
---|---|
static CycleDetectingLockFactory.Policy |
getPolicy() |
static void |
ignoreLockCycles() |
static ReentrantLock |
lock(String name) |
static void |
setPolicy(CycleDetectingLockFactory.Policy policy) |
static void |
throwOnLockCycles() |
static void |
waitForUserCode()
Put a dummy task into the queue and wait for it to be run.
|
static void |
warnOnLockCycles() |
public static Executor USER_THREAD
public static final Executor SAME_THREAD
MoreExecutors.sameThreadExecutor()
because the latter creates a new
object each time in order to implement the more complex ExecutorService
interface, which is overkill
for our needs.@Nullable public static volatile Thread.UncaughtExceptionHandler uncaughtExceptionHandler
public static CycleDetectingLockFactory factory
public static ListeningExecutorService THREAD_POOL
public static void waitForUserCode()
SettableFuture
and then call set
on it. You can then either block on that future, compose it, add listeners to it and so on.public static ReentrantLock lock(String name)
public static void warnOnLockCycles()
public static void throwOnLockCycles()
public static void ignoreLockCycles()
public static void setPolicy(CycleDetectingLockFactory.Policy policy)
public static CycleDetectingLockFactory.Policy getPolicy()
Copyright © 2016. All rights reserved.