Threading module

In addition to the thread module, we have another approach to using the threading module. The threading module relies on the thread module to provide us a higher level, more complete, and object-oriented API. The threading module is based slightly on the Java threads model.

The threading module contains a Thread class that we must extend to create our own threads of execution. The run method will contain the code that we want the thread to execute. If we want to specify our own constructor, it must call threading. Thread .__ init __ (self) to initialize the object correctly.

Before creating a new thread in Python, we review the Python Thread class init method constructor and see what parameters we need to pass in:

# Python ...

Get Mastering Python for Networking and Security now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.