| Modifier and Type | Class and Description | 
|---|---|
| private static interface  | Threads.PrintThreadInfoHelper | 
| private static class  | Threads.PrintThreadInfoLazyHolder | 
| Modifier and Type | Field and Description | 
|---|---|
| private static org.slf4j.Logger | LOG | 
| static Thread.UncaughtExceptionHandler | LOGGING_EXCEPTION_HANDLER | 
| Constructor and Description | 
|---|
| Threads() | 
| Modifier and Type | Method and Description | 
|---|---|
| static ThreadPoolExecutor | getBoundedCachedThreadPool(int maxCachedThread,
                          long timeout,
                          TimeUnit unit,
                          ThreadFactory threadFactory)Create a new CachedThreadPool with a bounded number as the maximum
 thread size in the pool. | 
| static void | printThreadInfo(PrintStream stream,
               String title)Print all of the thread's information and stack traces. | 
| static <T extends Thread> | setDaemonThreadRunning(T t)Utility method that sets name, daemon status and starts passed thread. | 
| static <T extends Thread> | setDaemonThreadRunning(T t,
                      String name)Utility method that sets name, daemon status and starts passed thread. | 
| static <T extends Thread> | setDaemonThreadRunning(T t,
                      String name,
                      Thread.UncaughtExceptionHandler handler)Utility method that sets name, daemon status and starts passed thread. | 
| static void | setLoggingUncaughtExceptionHandler(Thread t)Sets an UncaughtExceptionHandler for the thread which logs the
 Exception stack if the thread dies. | 
| static void | shutdown(Thread t)Shutdown passed thread using isAlive and join. | 
| static void | shutdown(Thread t,
        long joinwait)Shutdown passed thread using isAlive and join. | 
| static void | sleep(long millis)If interrupted, just prints out the interrupt on STDOUT, resets interrupt and returns | 
| static void | sleepWithoutInterrupt(long msToWait)Sleeps for the given amount of time even if interrupted. | 
| static void | threadDumpingIsAlive(Thread t) | 
private static final org.slf4j.Logger LOG
public static final Thread.UncaughtExceptionHandler LOGGING_EXCEPTION_HANDLER
public Threads()
public static <T extends Thread> T setDaemonThreadRunning(T t)
t - thread to runt.public static <T extends Thread> T setDaemonThreadRunning(T t, String name)
t - thread to frobname - new namet.public static <T extends Thread> T setDaemonThreadRunning(T t, String name, Thread.UncaughtExceptionHandler handler)
t - thread to frobname - new namehandler - A handler to set on the thread. Pass null if want to use default handler.t.public static void shutdown(Thread t)
t - Thread to shutdownpublic static void shutdown(Thread t, long joinwait)
joinwait - Pass 0 if we're to wait forever.t - Thread to shutdownpublic static void threadDumpingIsAlive(Thread t) throws InterruptedException
t - Waits on the passed thread to die dumping a threaddump every
 minute while its up.InterruptedExceptionpublic static void sleep(long millis)
millis - How long to sleep for in milliseconds.public static void sleepWithoutInterrupt(long msToWait)
msToWait - the amount of time to sleep in millisecondspublic static ThreadPoolExecutor getBoundedCachedThreadPool(int maxCachedThread, long timeout, TimeUnit unit, ThreadFactory threadFactory)
maxCachedThread - the maximum thread could be created in the pooltimeout - the maximum time to waitunit - the time unit of the timeout argumentthreadFactory - the factory to use when creating new threadspublic static void setLoggingUncaughtExceptionHandler(Thread t)
public static void printThreadInfo(PrintStream stream, String title)
stream - the stream totitle - a string title for the stack traceCopyright © 2007–2021 The Apache Software Foundation. All rights reserved.