<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def stop(self):
 """ Signals the worker threads to exit and waits on them. """

        if not self.stopped():
            self._stop.set()
            for worker in self._workers:
                worker.join()