code: static public Thread[] getAllThreadsMatching(final String regex) {
          if (regex == null)
              throw new NullPointerException("Null thread name regex");
          final Thread[] threads = getAllThreads();
          ArrayList<Thread> matchingThreads = new ArrayList<Thread>();
          for (Thread thread : threads) {
              if (thread.getName().matches(regex)) {
                  matchingThreads.add(thread);
              }
          }
          return matchingThreads.toArray(new Thread[0]);
      }
docs: Gets all threads if its name matches a regular expression.  For example,
  using a regex of "main" will execute a case-sensitive match for threads
  with the exact name of "main".  A regex of ".*main.*" will execute a
  case sensitive match for threads with "main" anywhere in their name. A
  regex of "(?i).*main.*" will execute a case insensitive match of any
  thread that has "main" in its name.
  @param regex The regular expression to use when matching a threads name.
  Same rules apply as String.matches() method.
  @return An array (will not be null) of all matching threads.  An empty
  array will be returned if no threads match.