com.bea.jvm
Interface ThreadSnapshot

All Superinterfaces:
Describable

public interface ThreadSnapshot
extends Describable

Interface representing a snapshot of a thread's state at a given time. Note that when this object is created, the thread and state it represents may have died and been garbage collected already.

Author:
Calle Wilund, Marcus Hirt

Nested Class Summary
static interface ThreadSnapshot.Monitor
           Interface representing a monitor from a specific thread snapshot.
 
Field Summary
static int STATE_ALIVE
          Thread "JVMTI" bit state for a living thread
static int STATE_BLOCKED_ON_MONITOR_ENTER
          Thread "JVMTI" bit state for a thread blocked when trying to enter a synchronized block
static int STATE_IN_NATIVE
          Thread "JVMTI" bit state for a thread running native code
static int STATE_IN_OBJECT_WAIT
          Thread "JVMTI" bit state for a thread which has called Object.wait
static int STATE_INTERRUPTED
          Thread "JVMTI" bit state for a interrupted thread
static int STATE_NEW
          Thread "JVMTI" bit state for a not yet started thread
static int STATE_PARKED
          Thread "JVMTI" bit state for a parked thread
static int STATE_RUNNABLE
          Thread "JVMTI" bit state for a thread in a runnable state
static int STATE_SLEEPING
          Thread "JVMTI" bit state for a thread which has called Thread.sleep
static int STATE_SUSPENDCRITICAL
          Additional JRockit thread bit state for a thread in suspend critical code.
static int STATE_SUSPENDED
          Thread "JVMTI" bit state for a suspended thread
static int STATE_TERMINATED
          Thread "JVMTI" bit state for a terminated thread
static int STATE_THIN_LOCK
          Additional JRockit thread bit state for a thread blocked on a thin lock.
static int STATE_WAITING
          Thread "JVMTI" bit state for a waiting thread
static int STATE_WAITING_INDEFINITELY
          Thread "JVMTI" bit state for a thread waiting without timeout
static int STATE_WAITING_WITH_TIMEOUT
          Thread "JVMTI" bit state for a thread waiting with timeout
static int THREAD_STATE_ACTIVE
          Thread state for an active thread.
static int THREAD_STATE_IO
          Thread state for a thread waiting for IO.
static int THREAD_STATE_LOCKED
          Thread state for a thread blocked trying to take a lock.
static int THREAD_STATE_SUSPENDED
          Thread state for a suspended thread.
static int THREAD_STATE_WAITING
          Thread state for a thread waiting on notification.
 
Method Summary
 ThreadSnapshot.Monitor getBlockedOnMonitor()
          Return the monitor this thread is blocked on, or null if none.
 java.lang.String getDescription()
          Returns the snapshot as a String.
 long getID()
          Returns the id of the thread that the snapshot was created for.
 java.lang.String getName()
          Returns the name of the thread that this snapshot was created from.
 int getPriority()
          Returns the priority level of the thread at the time of the snapshot.
 java.util.List getStackTrace()
          Returns a list of CallTraceElement.
 int getState()
          Deprecated. Use the new getStateBitmap or getThreadState instead.
 int getStateBitmap()
          Returns a bitmap describing the thread state.
 java.lang.Object getThreadState()
          Return an Object describing the Thread state representing the state bitmap.
 ThreadSnapshot.Monitor getWaitingOnMonitor()
          Return the monitor this thread is waiting on, or null if none.
 boolean isDaemon()
          Returns true if this thread is a daemon thread.
 

Field Detail

STATE_NEW

static final int STATE_NEW
Thread "JVMTI" bit state for a not yet started thread

See Also:
Constant Field Values

STATE_ALIVE

static final int STATE_ALIVE
Thread "JVMTI" bit state for a living thread

See Also:
Constant Field Values

STATE_TERMINATED

static final int STATE_TERMINATED
Thread "JVMTI" bit state for a terminated thread

See Also:
Constant Field Values

STATE_RUNNABLE

static final int STATE_RUNNABLE
Thread "JVMTI" bit state for a thread in a runnable state

See Also:
Constant Field Values

STATE_WAITING_INDEFINITELY

static final int STATE_WAITING_INDEFINITELY
Thread "JVMTI" bit state for a thread waiting without timeout

See Also:
Constant Field Values

STATE_WAITING_WITH_TIMEOUT

static final int STATE_WAITING_WITH_TIMEOUT
Thread "JVMTI" bit state for a thread waiting with timeout

See Also:
Constant Field Values

STATE_SLEEPING

static final int STATE_SLEEPING
Thread "JVMTI" bit state for a thread which has called Thread.sleep

See Also:
Constant Field Values

STATE_WAITING

static final int STATE_WAITING
Thread "JVMTI" bit state for a waiting thread

See Also:
Constant Field Values

STATE_IN_OBJECT_WAIT

static final int STATE_IN_OBJECT_WAIT
Thread "JVMTI" bit state for a thread which has called Object.wait

See Also:
Constant Field Values

STATE_PARKED

static final int STATE_PARKED
Thread "JVMTI" bit state for a parked thread

See Also:
Constant Field Values

STATE_BLOCKED_ON_MONITOR_ENTER

static final int STATE_BLOCKED_ON_MONITOR_ENTER
Thread "JVMTI" bit state for a thread blocked when trying to enter a synchronized block

See Also:
Constant Field Values

STATE_SUSPENDED

static final int STATE_SUSPENDED
Thread "JVMTI" bit state for a suspended thread

See Also:
Constant Field Values

STATE_INTERRUPTED

static final int STATE_INTERRUPTED
Thread "JVMTI" bit state for a interrupted thread

See Also:
Constant Field Values

STATE_IN_NATIVE

static final int STATE_IN_NATIVE
Thread "JVMTI" bit state for a thread running native code

See Also:
Constant Field Values

STATE_THIN_LOCK

static final int STATE_THIN_LOCK
Additional JRockit thread bit state for a thread blocked on a thin lock. This corresponds to JVMTI vendor bit 1.

See Also:
Constant Field Values

STATE_SUSPENDCRITICAL

static final int STATE_SUSPENDCRITICAL
Additional JRockit thread bit state for a thread in suspend critical code. This corresponds to JVMTI vendor bit 2.

See Also:
Constant Field Values

THREAD_STATE_ACTIVE

static final int THREAD_STATE_ACTIVE
Thread state for an active thread.

See Also:
Constant Field Values

THREAD_STATE_IO

static final int THREAD_STATE_IO
Thread state for a thread waiting for IO.

See Also:
Constant Field Values

THREAD_STATE_WAITING

static final int THREAD_STATE_WAITING
Thread state for a thread waiting on notification.

See Also:
Constant Field Values

THREAD_STATE_LOCKED

static final int THREAD_STATE_LOCKED
Thread state for a thread blocked trying to take a lock.

See Also:
Constant Field Values

THREAD_STATE_SUSPENDED

static final int THREAD_STATE_SUSPENDED
Thread state for a suspended thread.

See Also:
Constant Field Values
Method Detail

getName

java.lang.String getName()
Returns the name of the thread that this snapshot was created from.

Returns:
the name of the thread.

getDescription

java.lang.String getDescription()
Returns the snapshot as a String. This equals doing toString() on the snapshot.

Specified by:
getDescription in interface Describable
Returns:
the snapshot as a String.
See Also:
Describable.getDescription()

getState

int getState()
Deprecated. Use the new getStateBitmap or getThreadState instead.

Returns the thread state (or as close as we can describe using the THREAD_STATE_ constants).

Returns:
the thread state.
See Also:
THREAD_STATE_ACTIVE, THREAD_STATE_IO, THREAD_STATE_WAITING, THREAD_STATE_LOCKED, THREAD_STATE_SUSPENDED

getStateBitmap

int getStateBitmap()
Returns a bitmap describing the thread state. The bitmap returned is identical to the value returned by the JVMTI GetThreadState call. See the JVMTI documentation for details.

The bitmap can be examined using the STATE_ constants defined in this interface.

See Also:
getThreadState()

getThreadState

java.lang.Object getThreadState()
Return an Object describing the Thread state representing the state bitmap. In an jdk 1.5 compatible VM this object will be a Thread.State enum, identical to what would have been returned by the getThreadState method on the java.lang.Thread object itself. This information is less detailed than the one returned by getStateBitmap. In a jdk 1.4 VM the returned Object is only guaranteed to be printable to human-readable form through toString()

See Also:
getStateBitmap(), Thread.getState()

getID

long getID()
Returns the id of the thread that the snapshot was created for.

Returns:
the id of the thread.

isDaemon

boolean isDaemon()
Returns true if this thread is a daemon thread.

Returns:
true if this thread is a deamon thread.

getPriority

int getPriority()
Returns the priority level of the thread at the time of the snapshot.

Returns:
the priority level of the thread at the time of the snapshot.

getStackTrace

java.util.List getStackTrace()
Returns a list of CallTraceElement.

Returns:
a list of CallTraceElement.
See Also:
CallTraceElement

getBlockedOnMonitor

ThreadSnapshot.Monitor getBlockedOnMonitor()
Return the monitor this thread is blocked on, or null if none. A thread is blocked on a monitor if it is trying to enter a synchronized-block but the monitor is already taken by another thread. This thread then gets "blocked" on this monitor. If this is the case, this method return the monitor the thread is blocked on.

Returns:
the monitor this thread is blocked on, or null.

getWaitingOnMonitor

ThreadSnapshot.Monitor getWaitingOnMonitor()
Return the monitor this thread is waiting on, or null if none. If a thread calls Object.wait()on a monitor, the thread is said to be "waiting" on this monitor. If this is the case, this method return the monitor the thread is waiting on. Note that the thread needs to take the monitor before being able to wait on it, but that the monitor is actually released before waiting on it. Therefore, if this method returns non-null, then the corresponding monitor will also be returned by a call to CallTraceElement.getMonitors()for one stack trace element, however, this monitor is currently not held by the thread, for this reason.

Returns:
the monitor this thread is waiting on, or null.


Copyright © 2006 BEA Systems Inc.