コード例 #1
1
  private static void showThreads(PrintStream pw, ThreadGroup g, Thread current) {
    int nthreads = g.activeCount();
    pw.println("\nThread Group = " + g.getName() + " activeCount= " + nthreads);
    Thread[] tarray = new Thread[nthreads];
    int n = g.enumerate(tarray, false);

    for (int i = 0; i < n; i++) {
      Thread thread = tarray[i];
      ClassLoader loader = thread.getContextClassLoader();
      String loaderName = (loader == null) ? "Default" : loader.getClass().getName();
      Thread.State state = thread.getState();
      long id = thread.getId();
      pw.print("   " + id + " " + thread.getName() + " " + state + " " + loaderName);
      if (thread == current) pw.println(" **** CURRENT ***");
      else pw.println();
    }

    int ngroups = g.activeGroupCount();
    ThreadGroup[] garray = new ThreadGroup[ngroups];
    int ng = g.enumerate(garray, false);
    for (int i = 0; i < ng; i++) {
      ThreadGroup nested = garray[i];
      showThreads(pw, nested, current);
    }
  }
コード例 #2
1
ファイル: Debug.java プロジェクト: umairwaheed/BitMate
  public static void killAWTThreads(ThreadGroup threadGroup) {
    Thread[] threadList = new Thread[threadGroup.activeCount()];

    threadGroup.enumerate(threadList);

    for (int i = 0; i < threadList.length; i++) {

      Thread t = threadList[i];

      if (t != null) {

        String name = t.getName();

        if (name.startsWith("AWT")) {

          out("Interrupting thread '".concat(t.toString()).concat("'"));

          t.interrupt();
        }
      }
    }

    if (threadGroup.getParent() != null) {

      killAWTThreads(threadGroup.getParent());
    }
  }
コード例 #3
0
 synchronized Object WaitForResponse(Thread t) {
   while (!response_set) {
     try {
       InlineJavaUtils.debug(3, "waiting for callback response in " + t.getName() + "...");
       wait();
     } catch (InterruptedException ie) {
       // Do nothing, return and wait() some more...
     }
   }
   InlineJavaUtils.debug(3, "got callback response");
   Object resp = response;
   response = null;
   response_set = false;
   return resp;
 }
コード例 #4
0
 public boolean runMacroTool(String name) {
   for (int i = 0; i < nMacros; i++) {
     if (macroNames[i].startsWith(name)) {
       if (macroToolThread != null
           && macroToolThread.getName().indexOf(name) != -1
           && macroToolThread.isAlive())
         return false; // do nothing if this tool is already running
       MacroRunner mw = new MacroRunner(pgm, macroStarts[i], name, (String) null);
       macroToolThread = mw.getThread();
       // IJ.log("runMacroTool: "+macroToolThread);
       return true;
     }
   }
   return false;
 }
コード例 #5
0
ファイル: Utils.java プロジェクト: Bama4255/IRC-Extended
 private static void dumptg(ThreadGroup tg, PrintWriter out, int indent) {
   for (int o = 0; o < indent; o++) out.print("\t");
   out.println("G: \"" + tg.getName() + "\"");
   Thread[] ths = new Thread[tg.activeCount() * 2];
   ThreadGroup[] tgs = new ThreadGroup[tg.activeGroupCount() * 2];
   int nt = tg.enumerate(ths, false);
   int ng = tg.enumerate(tgs, false);
   for (int i = 0; i < nt; i++) {
     Thread ct = ths[i];
     for (int o = 0; o < indent + 1; o++) out.print("\t");
     out.println("T: \"" + ct.getName() + "\"");
   }
   for (int i = 0; i < ng; i++) {
     ThreadGroup cg = tgs[i];
     dumptg(cg, out, indent + 1);
   }
 }
コード例 #6
0
    @Override
    public void run() {
      byte[] buf = new byte[100];
      try {
        int len;
        while ((len = in.read(buf)) > 0) {
          String output = new String(buf, 0, len);
          Thread t = Thread.currentThread();
          System.out.println(
              "thread " + t.getName() + " " + t.getId() + ", read " + len + " bytes: " + output);
        }

      } catch (IOException e) {
        logger.log(Level.SEVERE, "Failed to read", e);

      } finally {
        try {
          in.close();
        } catch (IOException e) {
          logger.log(Level.SEVERE, "Failed to close", e);
        }
      }
    }
コード例 #7
0
 synchronized void NotifyOfResponse(Thread t) {
   InlineJavaUtils.debug(3, "notifying that callback has completed in " + t.getName());
   notify();
 }
コード例 #8
0
 private void checkWorkerContext() {
   Thread t = Thread.currentThread();
   if (!t.getName().startsWith("vert.x-worker-thread")) {
     throw new IllegalStateException("Not a worker thread");
   }
 }