threads and concurrency threading the threading module provides thread class and variety of synchronization primitives for writing multithreaded programs thread objects the thread class is used to represent separate thread of control new thread can be created as followsthread(group=nonetarget=nonename=noneargs=()kwargs={}this creates new thread instance group is none and is reserved for future extensions target is callable object invoked by the run(method when the thread starts by defaultit' nonemeaning that nothing is called name is the thread name by defaulta unique name of the form "thread-nis created args is tuple of arguments passed to the target function kwargs is dictionary of keyword arguments passed to target thread instance supports the following methods and attributest start(starts the thread by invoking the run(method in separate thread of control this method can be invoked only once run(this method is called when the thread starts by defaultit calls the target function passed in the constructor this method can also be redefined in subclasses of thread join([timeout]waits until the thread terminates or timeout occurs timeout is floating-point number specifying timeout in seconds thread cannot join itselfand it' an error to join thread before it has been started is_alive(returns true if the thread is alive and false otherwise thread is alive from the moment the start(method returns until its run(method terminates isalive(is an alias for this method in older code name the thread name this is string that is used for identification only and which can be changed to more meaningful value if desired (which may simplify debuggingin older codet getname(and setname(nameare used to manipulate the thread name ident an integer thread identifier if the thread has not yet startedthe value is none daemon the thread' boolean daemonic flag this must be set prior to calling start(and the initial value is inherited from daemonic status of the creating thread the entire python program exits when no active non-daemon threads are left all programs have main lib fl ff