Lecture 19: Threading Basics
Eng. Emanuel Rashayi
Faculty of Engineering, Dept of Electrical & Electronics Engineering , University of Zimbabwe
erashayi@eng.uz.ac.zw
Python 3 - Threading Basics
Every process running inside an operating system contains at least one thread and
can further initiate multiple threads, which are then executed simultaneously, in the
same process space.
This is similar to executing multiple applications, at the same time.
In Python, threading can be used to run several function calls or other tasks
concurrently, especially if those tasks involve some waiting times.
This is the case for networking and web-related tasks, among others.
Python provides a specific module for threading purposes; this module is simply called
threading and it is a built-in module.
Python 3 - Threading Basics
We will use the Thread class from within the threading module, written with a capital T,
prepended, of course, by the module name.
From within this class, the most useful and used methods are start() and join().
The start() method simply starts or initiates the thread.
The join() method makes sure the program waits for all threads to terminate
Python 3 - Threading Basics
Python 3 - Threading Basics