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 a thread for each non-null runnable in the provided array.
A standard ThreadFactory is used to create threads.The newly created threads are not started. |
static Thread[] |
createThreads(Runnable[] runnables,
ThreadFactory threadFactory)
Creates a thread for each non-null runnable in the provided array.
The provided ThreadFactory is used to create threads.The newly created threads are not started. |
static boolean |
interruptAndJoin(Thread t) |
static boolean |
interruptAndJoin(Thread t,
long waitTime) |
static boolean |
interruptAndJoinThreads(Collection<? extends Thread> threads) |
static boolean |
interruptAndJoinThreads(Collection<? extends Thread> threads,
long waitTimePerThread) |
static boolean |
interruptAndJoinThreads(Thread[] threads) |
static boolean |
interruptAndJoinThreads(Thread[] threads,
long waitTimePerThread) |
static void |
sleepUntilMs(long time) |
static void |
startThreads(Collection<? extends Thread> threads) |
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)
ThreadFactory is used to create threads.runnables - -public static Thread[] createThreads(Runnable[] runnables, ThreadFactory threadFactory)
ThreadFactory is used to create threads.runnables - -threadFactory - -public static boolean interruptAndJoinThreads(Thread[] threads)
threads - true if all threads were shut down, false otherwise.public static boolean interruptAndJoinThreads(Thread[] threads, long waitTimePerThread)
threads - waitTimePerThread - true if all threads were shut down, false otherwise.public static boolean interruptAndJoinThreads(Collection<? extends Thread> threads)
threads - true if all threads were shut down, false otherwise.public static boolean interruptAndJoinThreads(Collection<? extends Thread> threads, long waitTimePerThread)
threads - waitTimePerThread - true if all threads were shut down, false otherwise.public static void startThreads(Thread[] threads)
public static void startThreads(Collection<? extends Thread> threads)
Copyright © 2014. All Rights Reserved.