Python - Joining the Threads

The join() method in thread class blocks the calling thread until the thread whose join() method is called terminates. The termination may be either normal, because of an unhandled exception – or until the optional timeout occurs. It can be called many times. The join() raises a RuntimeError if an attempt is made to join the current thread. Attempt to join() a thread before it has been started also raises the same exception.




  • timeout − it should be a floating point number specifying a timeout for which the thread is to be blocked.

The join() method always returns None. you must call is_alive() after join() to decide whether a timeout happened – if the thread is still alive, the join() call timed out. When the timeout argument is not present or None, the operation will block until the thread terminates.

A thread can be joined many times.



is_alive() method

This method returns whether the thread is alive. It returns True just before calling run() method and until just after the run() method terminates.

Kickstart Your Career

Get certified by completing the course

Get Started