|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.util.Threads
@InterfaceAudience.Private public class Threads
Thread Utility
Field Summary | |
---|---|
protected static org.apache.commons.logging.Log |
LOG
|
Constructor Summary | |
---|---|
Threads()
|
Method Summary | |
---|---|
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 ThreadFactory |
getNamedThreadFactory(String prefix)
Returns a ThreadFactory that names each created thread uniquely,
with a common prefix. |
static ThreadFactory |
newDaemonThreadFactory(String prefix)
Same as {#newDaemonThreadFactory(String, UncaughtExceptionHandler)}, without setting the exception handler. |
static ThreadFactory |
newDaemonThreadFactory(String prefix,
Thread.UncaughtExceptionHandler handler)
Get a named ThreadFactory that just builds daemon threads. |
static Thread |
setDaemonThreadRunning(Thread t)
Utility method that sets name, daemon status and starts passed thread. |
static Thread |
setDaemonThreadRunning(Thread t,
String name)
Utility method that sets name, daemon status and starts passed thread. |
static Thread |
setDaemonThreadRunning(Thread t,
String name,
Thread.UncaughtExceptionHandler handler)
Utility method that sets name, daemon status and starts passed thread. |
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)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.commons.logging.Log LOG
Constructor Detail |
---|
public Threads()
Method Detail |
---|
public static Thread setDaemonThreadRunning(Thread t)
t
- thread to run
t
.public static Thread setDaemonThreadRunning(Thread t, String name)
t
- thread to frobname
- new name
t
.public static Thread setDaemonThreadRunning(Thread 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.
InterruptedException
public 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 threads
public static ThreadFactory getNamedThreadFactory(String prefix)
ThreadFactory
that names each created thread uniquely,
with a common prefix.
prefix
- The prefix of every created Thread's name
ThreadFactory
that names threadspublic static ThreadFactory newDaemonThreadFactory(String prefix)
public static ThreadFactory newDaemonThreadFactory(String prefix, Thread.UncaughtExceptionHandler handler)
ThreadFactory
that just builds daemon threads.
prefix
- name prefix for all threads created from the factoryhandler
- unhandles exception handler to set for all threads
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |