def run(self):
      """
      Calls next for all running threads.
      """
      queue = [self.next()]
      iterations = ticks = 0
      while queue:
         iterations += 1
         newqueue = []
         for result, continuation in queue:
            ticks += 1
            method_pseudo_threads._result = result
            result, continuations = continuation.next()
            if type(continuations) == types.ListType:
               for continuation in continuations:
                  newqueue.append((None, continuation))
            else:
               if continuations:
                     newqueue.append((result, continuations))
         queue = newqueue
      self.iterations, self.ticks = iterations, ticks
      return self._result

      Calls next for all running threads.
      
recipes/Python/474127_Simulating_concurrency/recipe-474127.py