|
JThreadKitTM v1.1.0 ( public members only)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.jthreadkit.ThreadTools
PrintStream* Contains some handy constants and methods for use with JThreadKit.
| Field Summary | |
static long |
NO_TIMEOUT
Used to hold the long value 0L for
the "wait forever" timeout. |
static String |
VERSION
The string representation of the version number for this version of JThreadKit. |
| Method Summary | |
static void |
execute(Runnable workBundle)
Runs the specified bundle of work asynchronously using another thread. |
static String |
getVersion()
Returns the version number of JThreadKit. |
static void |
join(Thread threadToWaitFor,
long msTimeout)
The calling thread waits (up to the specified timeout) for the specified thread to die. |
static boolean |
join(Thread threadToWaitFor,
long msTimeout,
boolean useTimedOutException)
The calling thread waits (up to the specified timeout) for the specified thread to die. |
static void |
print(String msg)
Prefixes the specified message with the name of the thread and prints the resulting line to the specified System.out. |
static void |
printErr(String msg)
Prefixes the specified message with the name of the thread and prints the resulting line to the specified System.err. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String VERSION
public static final long NO_TIMEOUT
long value 0L for
the "wait forever" timeout. When this value is passed for
a timeout value, the waiting will not timeout.| Method Detail |
public static void print(String msg)
System.out. This can be a useful tool for
illustrative or debugging purposes.public static void printErr(String msg)
System.err. This can be a useful tool for
illustrative or debugging purposes.public static final String getVersion()
public static boolean join(Thread threadToWaitFor,
long msTimeout,
boolean useTimedOutException)
throws InterruptedException,
TimedOutException,
IllegalArgumentException
false
is returned or a TimedOutException is thrown. Which
occurs depends on whether an exception was requested by
passing true for the third parameter:
useTimedOutException. If the specified thread does
die within the timeout period, true is returned.threadToWaitFor - the thread to wait on while still alive.msTimeout - the maximum number of milliseconds to wait for
threadToWaitFor to die. Must be greater than
0 or else an IllegalArgumentException
is thrown (ThreadTools.NO_TIMEOUT can
not be passed, if you can to wait forever,
see the join() method on Thread).useTimedOutException - if true and a timeout
occurs, a TimedOutException will be thrown. If
false and a timeout occurs, this method
returns false.true if the specified thread dies within
the timeout period, or false if a timeout occurred.InterruptedException - if the calling thread is interrupted
while waiting for the specified thread to die.TimedOutException - if useTimedOutException
is true and a timeout occurs.IllegalArgumentException - if msTimeout is
less than 1.
public static void join(Thread threadToWaitFor,
long msTimeout)
throws InterruptedException,
TimedOutException,
IllegalArgumentException
TimedOutException is thrown, otherwise the method just
returns.threadToWaitFor - the thread to wait on while still alive.msTimeout - the maximum number of milliseconds to wait for
threadToWaitFor to die. Must be greater than
0 or else an IllegalArgumentException
is thrown (ThreadTools.NO_TIMEOUT can
not be passed, if you can to wait forever,
see the join() method on Thread).InterruptedException - if the calling thread is interrupted
while waiting for the specified thread to die.TimedOutException - if the timeout period expires before
the specified thread dies.IllegalArgumentException - if msTimeout is
less than 1.public static void execute(Runnable workBundle)
static instance
of BottomlessThreadPool to run the task. Since the pool
is "bottomless", the task will always get a thread to run it
(up to the limits of the VM of course!).
When this method returns, the run() method of the
workBundle may or may not have already
been called by the helper thread--you can't count on either case.
workBundle - the Runnable to pass off to the helper thread.
|
JThreadKitTM v1.1.0 ( public members only)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||