コード例 #1
0
 private void commandKill(StringTokenizer t) throws NoSessionException {
   // ### Should change the way in which thread ids and threadgroup names
   // ### are distinguished.
   if (!t.hasMoreTokens()) {
     env.error("Usage: kill <threadgroup name> or <thread id>");
     return;
   }
   while (t.hasMoreTokens()) {
     String idToken = t.nextToken();
     ThreadReference thread = findThread(idToken);
     if (thread != null) {
       runtime.stopThread(thread);
       env.notice("Thread " + thread.name() + " killed.");
       return;
     } else {
       /* Check for threadgroup name, NOT skipping "system". */
       // ### Should skip "system"?  Classic 'jdb' does this.
       // ### Should deal with possible non-uniqueness of threadgroup names.
       ThreadGroupIterator itg = allThreadGroups();
       while (itg.hasNext()) {
         ThreadGroupReference tg = itg.nextThreadGroup();
         if (tg.name().equals(idToken)) {
           ThreadIterator it = new ThreadIterator(tg);
           while (it.hasNext()) {
             runtime.stopThread(it.nextThread());
           }
           env.notice("Threadgroup " + tg.name() + "killed.");
           return;
         }
       }
       env.failure("\"" + idToken + "\" is not a valid threadgroup or id.");
     }
   }
 }
コード例 #2
0
 private ThreadReference[] threads() throws NoSessionException {
   if (threads == null) {
     ThreadIterator ti = new ThreadIterator(getDefaultThreadGroup());
     List<ThreadReference> tlist = new ArrayList<ThreadReference>();
     while (ti.hasNext()) {
       tlist.add(ti.nextThread());
     }
     threads = tlist.toArray(new ThreadReference[tlist.size()]);
   }
   return threads;
 }
コード例 #3
0
 private void commandResume(StringTokenizer t) throws NoSessionException {
   if (!t.hasMoreTokens()) {
     // Suspend all threads in the current thread group.
     // ### Issue: help message says default is all threads.
     // ### Behavior here agrees with 'jdb', however.
     ThreadIterator ti = currentThreadGroupThreads();
     while (ti.hasNext()) {
       // TODO - don't suspend debugger threads
       ti.nextThread().resume();
     }
     env.notice("All threads resumed.");
   } else {
     while (t.hasMoreTokens()) {
       ThreadReference thread = findThread(t.nextToken());
       if (thread != null) {
         // thread.resume();
         runtime.resumeThread(thread);
       }
     }
   }
 }