public class Threading extends 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 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 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 com.google.common.util.concurrent.CycleDetectingLockFactory.Policy |
getPolicy() |
static void |
ignoreLockCycles() |
static ReentrantLock |
lock(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 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 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 ReentrantLock lock(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()
Copyright © 2014. All rights reserved.