Exemplo n.º 1
0
  public static void removeThread(ThreadReference thread) {
    if (thread.equals(ThreadInfo.current)) {
      // Current thread has died.

      // Be careful getting the thread name. If its death happens
      // as part of VM termination, it may be too late to get the
      // information, and an exception will be thrown.
      String currentThreadName;
      try {
        currentThreadName = "\"" + thread.name() + "\"";
      } catch (Exception e) {
        currentThreadName = "";
      }

      setCurrentThread(null);

      err.println(
          String.format("%s, Current thread died. Execution continuing...", currentThreadName));
    }
    threads.remove(getThreadInfo(thread));
  }