|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnl.knowledgeplaza.util.ThreadUtil
public class ThreadUtil
This class provides a thread local stop flag, which a thread may query to see if it needs to stop. Aside for the stopflag it also implements a thread related store and some utility methods.
| Field Summary | |
|---|---|
static String |
SOURCECODE_VERSION
Standard variable for determining version of a class file. |
| Constructor Summary | |
|---|---|
ThreadUtil()
|
|
| Method Summary | |
|---|---|
static Object |
get(Runnable runnable,
String key)
fetch a specific value for this thread |
static Object |
get(String key)
|
static Object |
get(ThreadGroup runnable,
String key)
fetch a specific value for this thread |
static String |
getStackTrace()
get the stack trace of the current thread as a String |
static boolean |
getStopFlag()
query the stop flag for the current thread |
static boolean |
getStopFlag(Runnable pRunnable)
query the stop flag for the specified Thread/Runnable |
static void |
main(String[] args)
|
static boolean |
mayContinue()
may the current thread continue |
static boolean |
mustStop()
should the current thread stop |
static Object |
remove(Runnable runnable,
String key)
Remove a specific value for this thread |
static Object |
remove(String key)
|
static void |
remove(ThreadGroup runnable,
String key)
Remove a specific value for this thread |
static Thread |
replaceThread(Thread originalThread,
String name,
Runnable newRunnable)
Replace a thread with a new one (that is: the old thread is order to stop using the StopFlag and only then the new thread is allowed to commence) Note: the new thread is created immediatly, it only waits for the old one to stop. |
void |
runDelayed(int milleseconds,
Runnable runnable)
Execute something delayed |
static void |
setStopFlag(boolean pStop)
set the stop flag for the current thread |
static void |
setStopFlag(Runnable pRunnable,
boolean pStop)
set the stop flag for the specified Thread/Runnable |
static void |
sleep(int milliseconds)
Thread.sleep with an ignored InterruptedException |
static void |
sleep(long milliseconds)
Thread.sleep with an ignored InterruptedException |
static void |
sleepForced(int milliseconds)
Thread.sleep where an InterruptedException does not exit sleep |
static void |
sleepForced(long sleeptime)
Thread.sleep where an InterruptedException does not exit sleep |
static void |
store(Runnable runnable,
String key,
Object value)
Store a specific value for this thread |
static void |
store(String key,
Object value)
|
static void |
store(ThreadGroup runnable,
String key,
Object value)
Store a specific value for this thread |
static void |
waitForThreadToFinish(Thread thread)
Wait indefinitely for a thread to finish. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String SOURCECODE_VERSION
| Constructor Detail |
|---|
public ThreadUtil()
| Method Detail |
|---|
public static boolean mayContinue()
public static boolean mustStop()
public static boolean getStopFlag()
public static void setStopFlag(boolean pStop)
public static boolean getStopFlag(Runnable pRunnable)
public static void setStopFlag(Runnable pRunnable,
boolean pStop)
public static void store(Runnable runnable,
String key,
Object value)
public static void store(String key,
Object value)
public static Object get(Runnable runnable,
String key)
public static Object get(String key)
public static Object remove(Runnable runnable,
String key)
public static Object remove(String key)
public static void store(ThreadGroup runnable,
String key,
Object value)
public static Object get(ThreadGroup runnable,
String key)
public static void remove(ThreadGroup runnable,
String key)
public static void sleep(int milliseconds)
milliseconds - public static void sleep(long milliseconds)
milliseconds - public static void sleepForced(int milliseconds)
milliseconds - public static void sleepForced(long sleeptime)
sleeptime - in millisecondspublic static void waitForThreadToFinish(Thread thread)
thread - public static String getStackTrace()
public static Thread replaceThread(Thread originalThread,
String name,
Runnable newRunnable)
public void runDelayed(int milleseconds,
Runnable runnable)
milleseconds - runnable - public static void main(String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||