ch.bind.philib.lang
public abstract class ThreadUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ThreadUtil.ForeverRunner
Wrapper for a runnable.
|
| Modifier and Type | Field and Description |
|---|---|
static ThreadFactory |
DEFAULT_THREAD_FACTORY |
| Modifier | Constructor and Description |
|---|---|
protected |
ThreadUtil() |
| Modifier and Type | Method and Description |
|---|---|
static Thread[] |
createThreads(Runnable[] runnables)
Creates the number of requested threads or none at all.
|
static Thread[] |
createThreads(Runnable[] runnables,
ThreadFactory threadFactory)
Creates the number of requested threads or none at all.
|
static boolean |
interruptAndJoin(Thread t) |
static boolean |
interruptAndJoin(Thread t,
long waitTime) |
static boolean |
interruptAndJoinThreads(Thread[] threads) |
static boolean |
interruptAndJoinThreads(Thread[] threads,
long waitTimePerThread) |
static void |
sleepUntilMs(long time) |
static void |
startThreads(Thread[] threads) |
public static final ThreadFactory DEFAULT_THREAD_FACTORY
public static void sleepUntilMs(long time)
throws InterruptedException
InterruptedExceptionpublic static boolean interruptAndJoin(Thread t)
t - the thread which must be interrupted and joined with a default
timeouttrue for OK, false in case of an error.public static boolean interruptAndJoin(Thread t, long waitTime)
t - the thread which must be interruptedwaitTime - a specific timeout for the join operation. A negative or zero
value means to no timeout is implied.true for OK, false in case of an error.public static Thread[] createThreads(Runnable[] runnables)
runnables - threadFactory - public static Thread[] createThreads(Runnable[] runnables, ThreadFactory threadFactory)
runnables - threadFactory - public static boolean interruptAndJoinThreads(Thread[] threads)
threads - public static boolean interruptAndJoinThreads(Thread[] threads, long waitTimePerThread)
threads - waitTimePerThread - public static void startThreads(Thread[] threads)
Copyright © 2013. All Rights Reserved.