There’s more to working with multithreading than locking code and avoiding deadlocks. You also need to know how to synchronize activities. It’s not so hard once you understand.

Events are objects that you can create and wait on from one thread while signaling the event from another thread. When a thread is waiting for one or more events, it gets suspended so it doesn’t continue to consume processor time or resources. And when a thread wakes up from waiting, then it knows that the event it was waiting for has happened. That is assuming a wait timeout didn’t happen first.

Specifying a timeout value is a good idea when you have other work your thread could be doing or you want to just give up and try something different.

For the thread that signals an event, it can usually choose to signal the event for all waiting threads or just a single thread.

And the last topic that this episode explains is how you can wait on objects other than events.


What's on your mind?
On a scale of 0 to 10, how likely are you to refer us to friends?