Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Joining Threads

Give Feedback

In this lesson, you’ll learn how to use the join() method to bring all your threads together before the main thread exits. If you download the sample code, you can get your own copy of 05-join.py:

Download

Sample Code (.zip)

12.9 KB

To learn more, you can also check out the documentation.

gnraju24 on July 30, 2020

course is going great till now. thanks for explanation with code

kiran on Aug. 28, 2020

difference between join() & demon thread?

Bartosz Zaczyński RP Team on Aug. 31, 2020

Just a side note: it’s not “demon” but a “daemon” thread.

.join() is a method on the threading.Thread class. You can call it from another thread to wait until the other one finishes its execution. It doesn’t matter whether you’re calling .join() on a regular or a daemon thread.

Regular threads running in the background will prevent Python from exiting even after the main thread has finished. On the other hand, daemon threads don’t have such power. They’ll stop abruptly when the main thread is done. For this reason, you should never use resources that require cleanup, such as files, in daemon threads.

Become a Member to join the conversation.