@classmethod
def wait(cls):
    """
        Sends shutdown signal to threads and waits for all threads and queues to
        terminate.
        """
    for queue in cls.queues.values():
        queue.put_nowait(None)
    for thread in cls.threads.values():
        thread.join()
