public static class BTraceUtils.Threads
extends java.lang.Object
Constructor and Description |
---|
BTraceUtils.Threads() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Thread |
currentThread()
Returns a reference to the currently executing thread object.
|
static void |
deadlocks()
Prints the Java level deadlocks detected (if any).
|
static void |
deadlocks(boolean stackTrace)
Prints deadlocks detected (if any).
|
static boolean |
holdsLock(java.lang.Object obj)
Returns true if and only if the current thread holds the
monitor lock on the specified object.
|
static boolean |
isInteruppted()
Tests whether this thread has been interrupted.
|
static void |
jstack()
Prints the java stack trace of the current thread.
|
static void |
jstack(int numFrames)
Prints the java stack trace of the current thread.
|
static void |
jstack(java.lang.Throwable exception)
Prints the stack trace of the given exception object.
|
static void |
jstack(java.lang.Throwable exception,
int numFrames)
Prints the stack trace of the given exception object.
|
static void |
jstackAll()
Prints Java stack traces of all the Java threads.
|
static void |
jstackAll(int numFrames)
Prints Java stack traces of all the Java threads.
|
static java.lang.String |
jstackAllStr()
Returns the stack traces of all Java threads as a String.
|
static java.lang.String |
jstackAllStr(int numFrames)
Returns atmost given number of frames in stack traces
of all threads as a String.
|
static java.lang.String |
jstackStr()
Returns the stack trace of current thread as a String.
|
static java.lang.String |
jstackStr(int numFrames)
Returns the stack trace of the current thread as a String
but includes atmost the given number of frames.
|
static java.lang.String |
jstackStr(java.lang.Throwable exception)
Returns the stack trace of given exception object as a String.
|
static java.lang.String |
jstackStr(java.lang.Throwable exception,
int numFrames)
Returns stack trace of given exception object as a String.
|
static java.lang.String |
name(java.lang.Thread thread)
Returns the name of the given thread.
|
static long |
threadId(java.lang.Thread thread)
Returns the identifier of the given Thread.
|
static java.lang.Thread.State |
threadState(java.lang.Thread thread)
Returns the state of the given thread.
|
public static boolean isInteruppted()
A thread interruption ignored because a thread was not alive at the time of the interrupt will be reflected by this method returning false.
true
if this thread has been interrupted;
false
otherwise.public static void jstack()
public static void jstack(int numFrames)
numFrames
- number of frames to be printed. When this is
negative all frames are printed.public static void jstackAll()
public static void jstackAll(int numFrames)
numFrames
- number of frames to be printed. When this is
negative all frames are printed.public static java.lang.String jstackStr()
public static java.lang.String jstackStr(int numFrames)
numFrames
- number of frames to be included. When this is
negative all frames are included.public static java.lang.String jstackAllStr()
public static java.lang.String jstackAllStr(int numFrames)
numFrames
- number of frames to be included. When this is
negative all frames are included.public static void jstack(java.lang.Throwable exception)
exception
- throwable for which stack trace is printed.public static void jstack(java.lang.Throwable exception, int numFrames)
exception
- throwable for which stack trace is printed.numFrames
- maximum number of frames to be printed.public static java.lang.String jstackStr(java.lang.Throwable exception)
exception
- the throwable for which stack trace is returned.public static java.lang.String jstackStr(java.lang.Throwable exception, int numFrames)
exception
- throwable for which stack trace is returned.numFrames
- maximum number of frames to be returned.public static java.lang.Thread currentThread()
public static long threadId(java.lang.Thread thread)
public static java.lang.Thread.State threadState(java.lang.Thread thread)
public static boolean holdsLock(java.lang.Object obj)
This method is designed to allow a program to assert that the current thread already holds a specified lock:
assert Thread.holdsLock(obj);
obj
- the object on which to test lock ownershipjava.lang.NullPointerException
- if obj is nullpublic static void deadlocks()
public static void deadlocks(boolean stackTrace)
stackTrace
- boolean flag to specify whether to
print stack traces of deadlocked threads or not.public static java.lang.String name(java.lang.Thread thread)
thread
- thread whose name is returned