1 33 34 package edu.rice.cs.drjava.model.debug; 35 36 import com.sun.jdi.*; 37 38 42 public class DebugThreadData { 43 private final ThreadReference _thread; 44 private final String _name; 45 private final String _status; 46 private final long _uniqueID; 47 48 52 public DebugThreadData(ThreadReference thread) { 53 _thread = thread; 54 String name; 55 try { 56 name = _thread.name(); 57 } 58 catch(VMDisconnectedException e) { 59 name = ""; 60 } 61 _name = name; 62 String status = "(unknown)"; 63 try{ 64 switch (_thread.status()) { 65 case ThreadReference.THREAD_STATUS_MONITOR: 66 status = "MONITOR"; break; 67 case ThreadReference.THREAD_STATUS_NOT_STARTED: 68 status = "NOT STARTED"; break; 69 case ThreadReference.THREAD_STATUS_RUNNING: 70 status = "RUNNING"; break; 71 case ThreadReference.THREAD_STATUS_SLEEPING: 72 status = "SLEEPING"; break; 73 case ThreadReference.THREAD_STATUS_UNKNOWN: 74 status = "UNKNOWN"; break; 75 case ThreadReference.THREAD_STATUS_WAIT: 76 status = "WAIT"; break; 77 case ThreadReference.THREAD_STATUS_ZOMBIE: 78 status = "ZOMBIE"; break; 79 } 80 } 81 catch (VMDisconnectedException e) { 82 } 84 if ( isSuspended() && status.equals("RUNNING") ) { 85 _status = "SUSPENDED"; 86 } 87 else{ 88 _status = status; 89 } 90 _uniqueID = _thread.uniqueID(); 91 } 92 93 96 public String getName() { 97 return _name; 98 } 99 100 103 public String getStatus() { 104 return _status; 105 } 106 107 public long getUniqueID() { 108 return _uniqueID; 109 } 110 111 115 public boolean isSuspended() { 116 try { 117 return _thread.isSuspended(); 118 } 119 catch (ObjectCollectedException oce) { 120 return false; 121 } 122 catch (VMDisconnectedException vmde) { 123 return false; 124 } 125 } 126 } 127 | Popular Tags |