The threading module allows multiple threads of execution to take place in a Python program.

While threads may appear to run simultaneously, only one thread can be executed at a time. This is enforced by Python’s global interpreter lock.

Threading is helpful when working with tasks that are I/O bound. This includes web-oriented tasks like scraping or downloading files.


import threading

The threading module must first be imported before thread constants can be created and their methods can be used.


Returns True if the thread is still running and False, otherwise.
Delays the flow of execution of a program until the target thread is completely read.
Returns a local thread object with data that is specific to that thread.
Executes any target function belonging to a given thread object that is now active.
Activates and prompts a thread object to be run.
Returns a thread object that can run a function with zero or more arguments.


Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn Python on Codecademy