public class Threading
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Threading.UserThread |
Modifier and Type | Field and Description |
---|---|
static com.google.common.util.concurrent.CycleDetectingLockFactory |
factory |
static java.util.concurrent.Executor |
SAME_THREAD
A dummy executor that just invokes the runnable immediately.
|
static com.google.common.util.concurrent.ListeningExecutorService |
THREAD_POOL
A caching thread pool that creates daemon threads, which won't keep the JVM alive waiting for more work.
|
static java.lang.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 java.util.concurrent.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 com.google.common.util.concurrent.CycleDetectingLockFactory.Policy |
getPolicy() |
static void |
ignoreLockCycles() |
static java.util.concurrent.locks.ReentrantLock |
lock(java.lang.String name) |
static void |
setPolicy(com.google.common.util.concurrent.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 java.util.concurrent.Executor USER_THREAD
public static final java.util.concurrent.Executor SAME_THREAD
ExecutorService
), which are overkill for our needs.@Nullable public static volatile java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler
public static com.google.common.util.concurrent.CycleDetectingLockFactory factory
public static com.google.common.util.concurrent.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 java.util.concurrent.locks.ReentrantLock lock(java.lang.String name)
public static void warnOnLockCycles()
public static void throwOnLockCycles()
public static void ignoreLockCycles()
public static void setPolicy(com.google.common.util.concurrent.CycleDetectingLockFactory.Policy policy)
public static com.google.common.util.concurrent.CycleDetectingLockFactory.Policy getPolicy()