12.3.10.5.1. Worker threadΒΆ

This example shows how to use the Python threading package.

import threading
import time


def worker():
    """thread worker function"""
    print("worker start")
    time.sleep(2)
    print("worker end")
    return


threads = []
for i in range(5):
    t = threading.Thread(target=worker)
    threads.append(t)
    t.start()