com.sun.btrace
Class BTraceUtils.Threads

java.lang.Object
  extended by com.sun.btrace.BTraceUtils.Threads
Enclosing class:
BTraceUtils

public static class BTraceUtils.Threads
extends java.lang.Object

Namespaced methods


Constructor Summary
BTraceUtils.Threads()
           
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BTraceUtils.Threads

public BTraceUtils.Threads()
Method Detail

isInteruppted

public static boolean isInteruppted()
Tests whether this thread has been interrupted. The interrupted status of the thread is unaffected by this method.

A thread interruption ignored because a thread was not alive at the time of the interrupt will be reflected by this method returning false.

Returns:
true if this thread has been interrupted; false otherwise.

jstack

public static void jstack()
Prints the java stack trace of the current thread.


jstack

public static void jstack(int numFrames)
Prints the java stack trace of the current thread. But, atmost given number of frames.

Parameters:
numFrames - number of frames to be printed. When this is negative all frames are printed.

jstackAll

public static void jstackAll()
Prints Java stack traces of all the Java threads.


jstackAll

public static void jstackAll(int numFrames)
Prints Java stack traces of all the Java threads. But, atmost given number of frames.

Parameters:
numFrames - number of frames to be printed. When this is negative all frames are printed.

jstackStr

public static java.lang.String jstackStr()
Returns the stack trace of current thread as a String.

Returns:
the stack trace as a String.

jstackStr

public 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.

Parameters:
numFrames - number of frames to be included. When this is negative all frames are included.
Returns:
the stack trace as a String.

jstackAllStr

public static java.lang.String jstackAllStr()
Returns the stack traces of all Java threads as a String.

Returns:
the stack traces as a String.

jstackAllStr

public static java.lang.String jstackAllStr(int numFrames)
Returns atmost given number of frames in stack traces of all threads as a String.

Parameters:
numFrames - number of frames to be included. When this is negative all frames are included.
Returns:
the stack traces as a String.

jstack

public static void jstack(java.lang.Throwable exception)
Prints the stack trace of the given exception object.

Parameters:
exception - throwable for which stack trace is printed.

jstack

public static void jstack(java.lang.Throwable exception,
                          int numFrames)
Prints the stack trace of the given exception object. But, prints atmost given number of frames.

Parameters:
exception - throwable for which stack trace is printed.
numFrames - maximum number of frames to be printed.

jstackStr

public static java.lang.String jstackStr(java.lang.Throwable exception)
Returns the stack trace of given exception object as a String.

Parameters:
exception - the throwable for which stack trace is returned.

jstackStr

public static java.lang.String jstackStr(java.lang.Throwable exception,
                                         int numFrames)
Returns stack trace of given exception object as a String.

Parameters:
exception - throwable for which stack trace is returned.
numFrames - maximum number of frames to be returned.

currentThread

public static java.lang.Thread currentThread()
Returns a reference to the currently executing thread object.

Returns:
the currently executing thread.

threadId

public static long threadId(java.lang.Thread thread)
Returns the identifier of the given Thread. The thread ID is a positive long number generated when the given thread was created. The thread ID is unique and remains unchanged during its lifetime. When a thread is terminated, the thread ID may be reused.


threadState

public static java.lang.Thread.State threadState(java.lang.Thread thread)
Returns the state of the given thread. This method is designed for use in monitoring of the system state, not for synchronization control.


holdsLock

public static boolean holdsLock(java.lang.Object obj)
Returns true if and only if the current thread holds the monitor lock on the specified object.

This method is designed to allow a program to assert that the current thread already holds a specified lock:

     assert Thread.holdsLock(obj);
 

Parameters:
obj - the object on which to test lock ownership
Returns:
true if the current thread holds the monitor lock on the specified object.
Throws:
java.lang.NullPointerException - if obj is null

deadlocks

public static void deadlocks()
Prints the Java level deadlocks detected (if any).


deadlocks

public static void deadlocks(boolean stackTrace)
Prints deadlocks detected (if any). Optionally prints stack trace of the deadlocked threads.

Parameters:
stackTrace - boolean flag to specify whether to print stack traces of deadlocked threads or not.

name

public static java.lang.String name(java.lang.Thread thread)
Returns the name of the given thread.

Parameters:
thread - thread whose name is returned