def main():
    with ProgressBar(title=Text('<b>Example of many parallel tasks.</b>'), bottom_toolbar=Text('<b>[Control-L]</b> clear  <b>[Control-C]</b> abort')) as pb:

        def run_task(label, total, sleep_time):
            for i in pb(range(total), label=label):
                time.sleep(sleep_time)
        threads = [threading.Thread(target=run_task, args=('First task', 50, 0.1)), threading.Thread(target=run_task, args=('Second task', 100, 0.1)), threading.Thread(target=run_task, args=('Third task', 8, 3)), threading.Thread(target=run_task, args=('Fourth task', 200, 0.1)), threading.Thread(target=run_task, args=('Fifth task', 40, 0.2)), threading.Thread(target=run_task, args=('Sixth task', 220, 0.1)), threading.Thread(target=run_task, args=('Seventh task', 85, 0.05)), threading.Thread(target=run_task, args=('Eight task', 200, 0.05))]
        for t in threads:
            t.daemon = True
            t.start()
        for t in threads:
            while t.is_alive():
                t.join(timeout=0.5)
def main():
    with ProgressBar(title=Text('<b>Example of many parallel tasks.</b>'), bottom_toolbar=Text('<b>[Control-L]</b> clear  <b>[Control-C]</b> abort')) as pb:

        def run_task(label, total, sleep_time):
            for i in pb(range(total), label=label):
                time.sleep(sleep_time)
        threads = [threading.Thread(target=run_task, args=('First task', 50, 0.1)), threading.Thread(target=run_task, args=('Second task', 100, 0.1)), threading.Thread(target=run_task, args=('Third task', 8, 3)), threading.Thread(target=run_task, args=('Fourth task', 200, 0.1)), threading.Thread(target=run_task, args=('Fifth task', 40, 0.2)), threading.Thread(target=run_task, args=('Sixth task', 220, 0.1)), threading.Thread(target=run_task, args=('Seventh task', 85, 0.05)), threading.Thread(target=run_task, args=('Eight task', 200, 0.05))]
        for t in threads:
            t.daemon = True
            t.start()
        for t in threads:
            while t.is_alive():
                t.join(timeout=0.5)