Getting ready

The Python threading module provides a Thread class that is used to run processes and functions in a different thread:

class threading.Thread(group=None, 
                       target=None, 
                       name=None, 
                       args=(), 
                       kwargs={})  

Here are the parameters of the Thread class:

  • group: This is the group value, which should be None; this is reserved for future implementations.
  • target: This is the function that is to be executed when you start a thread activity.
  • name: This is the name of the thread; by default, a unique name of the form of Thread-N is assigned to it.
  • args: This is the tuple of arguments that are to be passed to a target.
  • kwargs: This is the dictionary of keyword arguments that are to be used for the target function.

In the next section, let's learn about how to define a thread.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.146.184