Module 19
Multithreading
Learn thread-based application development and synchronization basics.
01
Threads Overview
Learn what a Python thread is, how MainThread differs from a child thread, and why a thread is one flow of control inside a program.
02
Function Threads
Start a Python child thread with threading.Thread, point it at a function, pass a tuple of arguments, and dispatch that function with start().
03
Class Threads
Run a method of a Python class on a child thread by passing that method as the Thread target and supplying the method arguments as a tuple.
04
Join and Status
Use is_alive and join so the Python main thread can see whether a child is running and can wait at one line until that child finishes.
05
Thread Locks
Protect a shared Python task with threading.Lock so one thread finishes the task before the next thread enters, and always release the lock.