## jde.debugger
Class ThreadCommands

    java.lang.Object
      |
      +--jde.debugger.ApplicationCommands
            |
            +--jde.debugger.ThreadCommands

public class ThreadCommands
extends ApplicationCommands

ThreadCommands.java

Handles thread related commands. Jump to '`suspend`', `resume`', '`interrupt`', `kill_thread`, '`get_thread`', '`get_thread`', '`get_object_monitors`', '`trace_threads`', '`cancel_trace_threads`'

Created: Fri Jul 30 16:04:07 1999

Since:
  0.1

Fields inherited from class jde.debugger.ApplicationCommands
`app, identifiableEventRequests, store`

Constructor Summary
`ThreadCommands(Application a, ObjectStore s)`

Method Summary
`void` `doCancelTraceThreads(java.lang.Integer cmd_id, java.util.List args)` 'cancel_trace_threads' command.
`void` `doGetObjectMonitors(java.lang.Integer cmd_id, java.util.List args)` 'get_object_monitors' command.
`void` `doGetThread(java.lang.Integer cmd_id, java.util.List args)` 'get_thread' command.
`void` `doGetThreads(java.lang.Integer cmd_id, java.util.List args)` List all threads.
`void` `doInterrupt(java.lang.Integer cmd_id, java.util.List args)` 'interrupt' command.
`void` `doKillThread(java.lang.Integer cmd_id, java.util.List args)` 'kill' command.
`void` `doResume(java.lang.Integer cmd_id, java.util.List args)` 'resume' command.
`void` `doSuspend(java.lang.Integer cmd_id, java.util.List args)` 'suspend' command.
`void` `doTraceThreads(java.lang.Integer cmd_id, java.util.List args)` 'trace_threads' command.
`(package private) static LispForm` `getAllThreadsInformation(com.sun.jdi.VirtualMachine vm, ObjectStore store)` Returns a representation of all the threads and threadgroups in the VM.
`(package private) static com.sun.jdi.ThreadReference` `getThread(com.sun.jdi.VirtualMachine vm, java.lang.String name)` Returns the thread corresponding to this name

Methods inherited from class jde.debugger.ApplicationCommands
`addIdentifiableRequest, deleteIdentifiableRequest`

Methods inherited from class java.lang.Object
`<clinit>, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait`

Constructor Detail

### ThreadCommands

    public ThreadCommands(Application a,
                          ObjectStore s)

Method Detail

### doSuspend

    public void doSuspend(java.lang.Integer cmd_id,
                          java.util.List args)
                   throws JDEException

  'suspend' command.

  Syntax:

       suspend [threadID]*

  Comments:
  - threadIDs can be retrieved using the get_threads command
  - if the list is omitted, the entire VM is suspended
  - threadIDs can refer to either threads or threadgroups.

### doResume

    public void doResume(java.lang.Integer cmd_id,
                         java.util.List args)
                  throws JDEException

  'resume' command.

  Syntax:

       resume [threadID]*

  Comments:
  - threadIDs can be retrieved using the get_threads command
  - if the list is omitted, the entire VM is resumed
  - threadIDs can refer to either threads or thereadgroups.

### doInterrupt

    public void doInterrupt(java.lang.Integer cmd_id,
                            java.util.List args)
                     throws JDEException

  'interrupt' command.

  Syntax:

       interrupt [threadID]+

  Comments:
  - threadID can be retrieved using the get_threads command
  - at least one threadId should be specified

### doKillThread

    public void doKillThread(java.lang.Integer cmd_id,
                             java.util.List args)
                      throws JDEException

  'kill' command. Kill a thread with a given exception object.

  Syntax:

       kill_thread threadID exceptionObjectID

  Comments:
  - threadID can be retrieved using the get_threads command
  - exceptionObjectID is the object id of a Throwable object. It can be created using the 'evaluate' command, or an existing throwable object can be used.

### doGetThreads

    public void doGetThreads(java.lang.Integer cmd_id,
                             java.util.List args)
                      throws JDEException

  List all threads. 'get_threads' command.

  Syntax:

       get_threads

  Returns:

       (jde-dbo-command-result cmd_id thread-info)

  Comments:
  - There are a couple of quirks regarding the reporting of thread state:
    - Quirk 1: Due to a bug in ThreadReference.isAtBreakpoint(), a thread will report a breakpoint at a location even if a threadFilter has been applied for the thread. ie, if test.Test.java:41 is your breakpoint, and you've applied a threadfilter saying you DON'T want an event if the thread == Thread-A, and you somehow suspend Thread-A at exactly that line, and do a 'get_threads'; Thread-A will report to be suspended on a breakpoint, although ordinarily it would have skipped it.
    - Quirk 2: There seems to be no way of reporting the status if the user does a Thread.suspend(). Well, it's deprecated anyways... *shrug*.

### getAllThreadsInformation

    static LispForm getAllThreadsInformation(com.sun.jdi.VirtualMachine vm,
                                             ObjectStore store)

  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" <tgID> "ThreadGroup-1"
                    (list
                      (list "Thread" <tID> "Thread-5" ...))
                    (list
                      (list "ThreadGroup" <tgID> "ThreadGroup-2"
                        (list
                          (list "Thread" <tID> "Thread-4"))
                        (list
                          (list "ThreadGroup" <tgID> "ThreadGroup-3"
                            (list)
                            (list
                              (list "Thread" <tID> "Thread-1" ...)))
                          (list "ThreadGroup" <tgID> "ThreadGroup-4"
                            (list)
                              (list
                                (list "Thread" <tID> "Thread-2" ...)
                                (list "Thread" <tID> "Thread-3" ...)))))))
                (list "ThreadGroup" <tgID> "ThreadGroup-5"
                  (list)
                    (list
                      (list "Thread" <tID> "Thread-6" ...))))

  Syntax:

       (list [top-level thread group]*)

  Parameters:
    `vm` - The virtual machine itself
    `store` - The object store where you should keep references to the thread ids. For details, see `ObjectStore`

### getThread

    static com.sun.jdi.ThreadReference getThread(com.sun.jdi.VirtualMachine vm,
                                                 java.lang.String name)

  Returns the thread corresponding to this name

### doGetThread

    public void doGetThread(java.lang.Integer cmd_id,
                            java.util.List args)
                     throws JDEException

  'get_thread' command. List a thread in more detail.

  Syntax:

       get_thread threadID

  Returns:

       (jde-dbo-command-result cmd_id detailed-thread-info)

  Comments:
  - The thread can be waiting for a monitor through entry into a synchronized method, the synchronized statement, or Object.wait(). The status() method can be used to differentiate between the first two cases and the third.

### doGetObjectMonitors

    public void doGetObjectMonitors(java.lang.Integer cmd_id,
                                    java.util.List args)
                             throws JDEException

  'get_object_monitors' command. Information about the monitors corresponding to a particular object.

  Syntax:

       get_object_monitors objectID

  Returns:

       (jde-dbo-command-result cmd_id object-monitors-info)

### doTraceThreads

    public void doTraceThreads(java.lang.Integer cmd_id,
                               java.util.List args)
                        throws JDEException

  'trace_threads' command.

  Syntax:

       trace_threads type [threadID]
            [suspend-policy]

  Comments:
  - type can be either "start" or "death"
  - If no threadID is specified, all the corresponding thread events are raised.

  See Also:
    `EventHandler.threadStartEvent(ThreadStartEvent)`, `EventHandler.threadDeathEvent(ThreadDeathEvent)`

### doCancelTraceThreads

    public void doCancelTraceThreads(java.lang.Integer cmd_id,
                                     java.util.List args)
                              throws JDEException

  'cancel_trace_threads' command.

  Syntax:

       cancel_trace_threads requestID

  Comments:
  - requestID is returned in the trace threads reply