from tqdm import * from queue import Queue from threading import Thread import time THREADS = 4 class WorkerThread(Thread): def __init__(self, queue): Thread.__init__(self) self.queue = queue def run(self): while True: pbar = self.queue.get() time.sleep(2) pbar.update() self.queue.task_done() queue = Queue() # Create worker threads for x in range(THREADS): worker = WorkerThread(queue) worker.daemon = True worker.start() pbar = tqdm(total=20) for tile in range(20): queue.put(pbar) pbar.close() queue.join()