Async Techniques and Examples in Python Transcripts
Chapter: Threads
Lecture: Visual of thread execution

Login or purchase this course to watch this video and the rest of the course contents.
0:00 It's always good to have a picture of what's going on in our code, in our programs as they run. Here's a picture that I drew
0:08 trying to simulate that, or visualize that for you in Python. So, this big box is our process and the process itself can kickoff different threads.
0:19 And those are the little gray arrows. The ..., that's just waiting. We have our main program is running
0:25 and then at some point it kicks off two additional threads does a little more work then waits for the two threads to finish
0:30 and then carries on working. So, this fork-join pattern, kick a bunch of work off wait for it to finish, and then carry on
0:37 is very common in threaded programing. And it's important to realize these threads are all in the same process. They all work on the same memory.
0:45 So, if I have a variable or a data structure in Python which is always the pointer pointers are shared data structures
0:51 per process in the global memory heap. If I have one of those, and different threads are working with it, it's the exact same object.
1:00 So we'll have to see, you're going to have to be kind of careful with your data structures and the state of your program.
1:05 When you're doing programing with threads in Python. So, here's a picture to keep in mind to help you visualize typically what's happening
1:11 with our threads in Python.

Talk Python's Mastodon Michael Kennedy's Mastodon