September 2018
Intermediate to advanced
426 pages
10h 46m
English
A thread is the mechanism for a program to perform a task several times in parallel. Therefore, in a script, we can launch the same task on a single processor a certain number of times.
For working with threads in Python, we have two options:
The thread module will allow us to work with multiple threads:
In this example, we create four threads, and each one prints a different message on the screen that is passed as a parameter in the thread_message (message) method.
You can find the following code in the threads_init.py file in threads subfolder:
import threadimport timenum_threads ...
Read now
Unlock full access