class_docstr: Class for managing threads which run concurrent Spark jobs.
  
  This maintains a primary dispatcher thread, plus 1 thread per Hyperopt trial.
  Each trial's thread runs 1 Spark job with 1 task.
docstr: Wait for the dispatcher and worker threads to finish.
  :param cancel_running_trials: If true, try to cancel all running trials.
docstr_tok: ["Wait","for","the","dispatcher","and","worker","threads","to","finish",".",":","param","cancel_running_trials",":","If","true",",","try","to","cancel","all","running","trials","."]
code: def wait_for_all_threads(self):
      """
      Wait for the dispatcher and worker threads to finish.
      :param cancel_running_trials: If true, try to cancel all running trials.
      """
      self._fmin_done = True
      self._dispatcher_thread.join()
      self._dispatcher_thread = None
      for task_thread in self._task_threads:
          task_thread.join()
      self._task_threads.clear()
  
imports: import copy
  import os
  import threading
  import time
  import timeit
  import traceback
  from hyperopt import base, fmin, Trials
  from hyperopt.base import validate_timeout, validate_loss_threshold, STATUS_OK
  from hyperopt.utils import coarse_utcnow, _get_logger, _get_random_id
label_desc: Use image node_id 14 for calling the _SparkFMinState obj's underlying member method code with example usage: obj.wait_for_all_threads() without return types