How can i check the status of a java Thread using JVMDI? (for deadlocks etc.)

Davanum Srinivas

// ThreadTool.java
class ThreadTool {
  public static final int THREAD_STATUS_UNKNOWN = -1;
  public static final int THREAD_STATUS_ZOMBIE = 0;
  public static final int THREAD_STATUS_RUNNING = 1;  
  public static final int THREAD_STATUS_SLEEPING = 2;
  public static final int THREAD_STATUS_MONITOR = 3;
  public static final int THREAD_STATUS_WAIT = 4;

  public static final int SUSPEND_STATUS_SUSPENDED = 1;  
  public static final int SUSPEND_STATUS_BREAK = 2;
		
  public static native int getThreadStatus (Thread t);

  static {
    System.loadLibrary ("ThreadTool");
  }
}

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class ThreadTool */

#ifndef _Included_ThreadTool
#define _Included_ThreadTool
#ifdef __cplusplus
extern "C" {
#endif
#undef ThreadTool_THREAD_STATUS_UNKNOWN
#define ThreadTool_THREAD_STATUS_UNKNOWN -1L
#undef ThreadTool_THREAD_STATUS_ZOMBIE
#define ThreadTool_THREAD_STATUS_ZOMBIE 0L
#undef ThreadTool_THREAD_STATUS_RUNNING
#define ThreadTool_THREAD_STATUS_RUNNING 1L
#undef ThreadTool_THREAD_STATUS_SLEEPING
#define ThreadTool_THREAD_STATUS_SLEEPING 2L
#undef ThreadTool_THREAD_STATUS_MONITOR
#define ThreadTool_THREAD_STATUS_MONITOR 3L
#undef ThreadTool_THREAD_STATUS_WAIT
#define ThreadTool_THREAD_STATUS_WAIT 4L
#undef ThreadTool_SUSPEND_STATUS_SUSPENDED
#define ThreadTool_SUSPEND_STATUS_SUSPENDED 1L
#undef ThreadTool_SUSPEND_STATUS_BREAK
#define ThreadTool_SUSPEND_STATUS_BREAK 2L
/*
 * Class:     ThreadTool
 * Method:    getThreadStatus
 * Signature: (Ljava/lang/Thread;)I
 */
JNIEXPORT jint JNICALL Java_ThreadTool_getThreadStatus
  (JNIEnv *, jclass, jobject);

#ifdef __cplusplus
}
#endif
#endif


/* ThreadTool.c */
#include <jni.h>
#include "ThreadTool.h"
#include <jvmdi.h>

JNIEXPORT jint JNICALL Java_ThreadTool_getThreadStatus
  (JNIEnv *env, jclass clazz, jobject thread)
{
  jint threadStatus;
  jint suspendStatus;
  jvmdiError error = JVMDI_GetThreadStatus (env, thread, &threadStatus, &suspendStatus);
  return (threadStatus);
}
More information can be found at:
JavaTM Virtual Machine Debug Interface Reference
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact