Thread (threading)
say it: “THRED-ing” /ˈθrɛdɪŋ/ or “THRED” /θrɛd/
Lets part of a program run alongside the rest, handy while waiting on things.
What is a thread?
A thread lets part of your program run alongside the rest, useful when the program spends time waiting, like on downloads.
import threading
def download(file):
print(f"Downloading {file}")
workers = [threading.Thread(target=download, args=(f,)) for f in ["a.pdf", "b.pdf"]]
for worker in workers:
worker.start()
for worker in workers:
worker.join() # wait for both
Level: Freelancer · More Python terms at this level
Updated