java.lang.Object | |
↳ | com.pnfsoftware.jeb.util.concurrent.ThreadUtil |
Utility methods to manipulate threads.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ThreadUtil() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
static Thread |
create(Runnable r)
Create a daemon thread.
| ||||||||||
static String |
formatStackTrace(int skipcnt)
Convenience method to generate the simplified stack trace of the caller, on a single line.
| ||||||||||
static String |
formatStackTrace(int skipcnt, String separator, boolean displayClassPackageName, boolean displayLineNumber)
Convenience method to generate the simplified stack trace of the caller.
| ||||||||||
static String |
formatStackTrace()
Convenience method to generate the simplified stack trace of the caller, on a single line.
| ||||||||||
static void |
interruptAndJoinUninterruptibly(Thread thread)
Interrupt the target thread and wait for it to terminate, uninterruptibly.
| ||||||||||
static void |
joinU(Thread thread)
Join a thread uninterruptibly.
| ||||||||||
static boolean |
monitor(Thread t, IMonitorInfoProvider provider)
Monitor a running thread, and attempt to terminate it after a dynamic timeout has elapsed.
| ||||||||||
static Thread |
start(Runnable r)
Create and start a new daemon thread.
| ||||||||||
static Thread |
start(String name, Runnable r)
Create and start a new daemon thread.
| ||||||||||
static boolean |
stop(Thread t)
Gracefully stop a running thread.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Create a daemon thread. The thread is not started.
r | the runnable |
---|
Convenience method to generate the simplified stack trace of the caller, on a single line.
skipcnt | how many top-level callers should be removed |
---|
Convenience method to generate the simplified stack trace of the caller.
skipcnt | how many top-level callers should be removed |
---|---|
separator | optional separator, use null for default (" < " ) |
Convenience method to generate the simplified stack trace of the caller, on a single line.
Interrupt the target thread and wait for it to terminate, uninterruptibly.
thread | target Thread |
---|
Join a thread uninterruptibly.
Note: after successfully joining, if an InterruptedException had arisen, the
interrupt
flag is re-armed.
thread | the thread to join on |
---|
Monitor a running thread, and attempt to terminate it after a dynamic timeout has elapsed.
This method is blocking. In order for this method to work properly and responsively,
the monitored thread should check for interruptions
regularly,
and should not disregard InterruptedExceptions.
t | the running thread |
---|---|
provider | information for the monitor (timeout, probingPeriod, etc.); if the probing period is invalid, it will be set to a default 100ms. |
Create and start a new daemon thread.
r | the runnable |
---|
Create and start a new daemon thread.
name | thread name |
---|---|
r | the runnable |
Gracefully stop a running thread. This method is blocking.
t | the running thread |
---|