...

/

Mechanisms for Interthread Communication (ITC)

Mechanisms for Interthread Communication (ITC)

Learn two mechanisms for interthread communication in Python.

We'll cover the following...

Python’s threading module provides two mechanisms for interthread communication:

  • Event
  • Condition

Event

An Event object is used to communicate between threads. It has an internal flag that threads can set or clear by using the set() and clear() methods.

Typical working

If thread 1 calls the wait() method, it will wait (block) if the internal flag has not yet been set. Thread 2 will set ...