code: def cmd(send, *_):
      
      thread_names = []
      for x in sorted(threading.enumerate(), key=lambda k: k.name):
          res = re.match(r'Thread-(\d+$)', x.name)
          if res:
              tid = int(res.group(1))
              # Handle the main server thread (permanently listed as _worker)
              if x._target.__name__ == '_worker':
                  thread_names.append((tid, "%s running server thread" % x.name))
              # Handle the multiprocessing pool worker threads (they don't have names beyond Thread-x)
              elif x._target.__module__ == 'multiprocessing.pool':
                  thread_names.append((tid, "%s running multiprocessing pool worker thread" % x.name))
          # Handle everything else including MainThread and deferred threads
          else:
              res = re.match(r'Thread-(\d+)', x.name)
              tid = 0
              if res:
                  tid = int(res.group(1))
              thread_names.append((tid, x.name))
      for x in sorted(thread_names, key=lambda k: k[0]):
          send(x[1])
docs: Enumerate threads.
  
      Syntax: {command}