1 19 20 package org.netbeans.modules.debugger.jpda.models; 21 22 import com.sun.jdi.ThreadGroupReference; 23 import com.sun.jdi.ThreadReference; 24 import java.util.Iterator ; 25 26 import java.util.List ; 27 28 import org.netbeans.api.debugger.jpda.JPDAThread; 29 import org.netbeans.api.debugger.jpda.JPDAThreadGroup; 30 import org.netbeans.modules.debugger.jpda.JPDADebuggerImpl; 31 import org.netbeans.spi.viewmodel.UnknownTypeException; 32 33 34 37 public class JPDAThreadGroupImpl implements JPDAThreadGroup { 38 39 private ThreadGroupReference tgr; 40 private JPDADebuggerImpl debugger; 41 42 public JPDAThreadGroupImpl (ThreadGroupReference tgr, JPDADebuggerImpl debugger) { 43 this.tgr = tgr; 44 this.debugger = debugger; 45 } 46 47 52 public JPDAThreadGroup getParentThreadGroup () { 53 ThreadGroupReference ptgr = tgr.parent (); 54 if (ptgr == null) return null; 55 return debugger.getThreadGroup(ptgr); 56 } 57 58 public JPDAThread[] getThreads () { 59 List l = tgr.threads (); 60 int i, k = l.size (); 61 JPDAThread[] ts = new JPDAThread [k]; 62 for (i = 0; i < k; i++) 63 ts [i] = debugger.getThread((ThreadReference) l.get (i)); 64 return ts; 65 } 66 67 public JPDAThreadGroup[] getThreadGroups () { 68 List l = tgr.threadGroups (); 69 int i, k = l.size (); 70 JPDAThreadGroup[] ts = new JPDAThreadGroup [k]; 71 for (i = 0; i < k; i++) 72 ts [i] = debugger.getThreadGroup((ThreadGroupReference) l.get (i)); 73 return ts; 74 } 75 76 public String getName () { 77 return tgr.name (); 78 } 79 80 public void resume () { 82 List threads = tgr.threads(); 83 for (Iterator it = threads.iterator(); it.hasNext(); ) { 84 JPDAThreadImpl thread = (JPDAThreadImpl) debugger.getThread((ThreadReference) it.next()); 85 thread.notifyToBeResumed(); 86 } 87 tgr.resume (); 88 } 89 90 public void suspend () { 92 tgr.suspend (); 93 List threads = tgr.threads(); 94 for (Iterator it = threads.iterator(); it.hasNext(); ) { 95 JPDAThreadImpl thread = (JPDAThreadImpl) debugger.getThread((ThreadReference) it.next()); 96 thread.notifySuspended(); 97 } 98 } 99 100 } 101 | Popular Tags |