1 package jde.debugger.command;
2 import java.util.Iterator;
4 import com.sun.jdi.ObjectReference;
5 import com.sun.jdi.ThreadGroupReference;
6 import com.sun.jdi.ThreadReference;
7 import jde.debugger.Etc;
8 import jde.debugger.JDEException;
23 * <li> threadIDs can be retrieved using the get_threads command
24 * <li> if the list is omitted, the entire VM is suspended
25 * <li> threadIDs can refer to either threads or threadgroups.
28 * @author Paul Kinnucan
29 * @version $Revision: 1.2 $
31 * Copyright (c) 2000, 2001, 2003 Paul Kinnucan
34 public class Suspend extends DebugProcessCommand {
38 * @exception jde.debugger.JDEException <description>
40 public void doCommand() throws JDEException {
41 // see if there are arguments (should be the thread id). if so, we
42 // suspend the thread ids passed. else, suspend the whole vm.
43 if (m_args.size() > 0) {
44 Iterator it = m_args.iterator();
45 while (it.hasNext()) {
47 Long uniqueID = Etc.safeGetLong(it.next(), "thread(group)");
49 ObjectReference oRef = (ObjectReference) m_debugger.getStore().get(uniqueID);
51 throw new JDEException("Invalid ThreadID, or the thread/threadgroup is dead");
52 } else if (oRef instanceof ThreadReference) {
53 ((ThreadReference) oRef).suspend();
54 } else if (oRef instanceof ThreadGroupReference) {
55 ((ThreadGroupReference) oRef).suspend();
57 throw new JDEException("The object is not a thread or a threadgroup");
60 m_debugger.signalCommandResult(m_cmdID, null, CMD_OK);
63 m_debugger.getVM().suspend();
64 m_debugger.signalCommandResult(m_cmdID, null, CMD_OK);
65 } catch (Exception ex) {
66 throw new JDEException("Unable to suspend the application");
71 public Object clone() {return new Suspend();}
76 * $Log: Suspend.java,v $
77 * Revision 1.2 2003/01/15 05:56:26 paulk
78 * Add Petter Mahlen's changes.
80 * Revision 1.1 2001/03/24 13:35:25 paulk
86 // End of Suspend.java