package jde.debugger.command; import jde.debugger.JDEException; import com.sun.jdi.ThreadGroupReference; import jde.debugger.Rep; import java.util.Iterator; import java.util.List; /** * List all threads. 'get_threads' command. *

* * Syntax: *

 * get_threads
 * 
* * Returns: *
 * (jde-dbo-command-result cmd_id {@link #doCommand thread-info})
 * 
* * Comments: * * * @author Paul Kinnucan * @version $Revision: 1.2 $ * @copyright Copyright (c) 2000, 2001, 2003 Paul Kinnucan * */ public class GetThreads extends DebugProcessCommand { /** * Returns a representation of all the threads and threadgroups * in the VM. For example: *
   *              ThreadGroup-1
   *                  +- ThreadGroup-2
   *                  |        +- ThreadGroup-3
   *                  |        |        \- Thread-1
   *                  |        +- ThreadGroup-4
   *                  |        |        +- Thread-2
   *                  |        |        \- Thread-3
   *                  |        \- Thread-4
   *                  \- Thread-5
   *              ThreadGroup-5
   *                  +- Thread-6
   *
   *
   *          (list
   *            (list "ThreadGroup"  "ThreadGroup-1"
   *              (list 
   *                (list "Thread"  "Thread-5" ...))
   *              (list 
   *                (list "ThreadGroup"  "ThreadGroup-2"
   *                  (list 
   *                    (list "Thread"  "Thread-4"))
   *                  (list 
   *                    (list "ThreadGroup"  "ThreadGroup-3"
   *                      (list)
   *                      (list 
   *                        (list "Thread"  "Thread-1" ...)))
   *                    (list "ThreadGroup"  "ThreadGroup-4"
   *                      (list)
   *                        (list
   *                          (list "Thread"  "Thread-2" ...)
   *                          (list "Thread"  "Thread-3" ...)))))))
   *          (list "ThreadGroup"  "ThreadGroup-5"
   *            (list)
   *              (list
   *                (list "Thread"  "Thread-6" ...))))
   * 
* Syntax: *
   * (list [{@link Rep#getThreadGroupRep top-level thread group}]*)
   * 
* * @exception jde.debugger.JDEException */ public void doCommand() throws JDEException { List l = m_debugger.getVM().topLevelThreadGroups(); Iterator it = l.iterator(); StringBuffer result = new StringBuffer("(list "); while (it.hasNext()) { // XXX may have to populate the ObjectStore here. result.append(BR); result.append(Rep.getThreadGroupRep((ThreadGroupReference)it.next())); } result.append(")"); m_debugger.signalCommandResult(m_cmdID, result.toString(), CMD_OK, NOQUOTE); } public Object clone() {return new GetThreads();} } // GetThreads /* * $Log: GetThreads.java,v $ * Revision 1.2 2003/01/15 05:56:26 paulk * Add Petter Mahlen's changes. * * Revision 1.1 2001/03/24 13:35:25 paulk * Initial revision. * * */ // End of GetThreads.java