inter thread/process synchronisation the output from this program isstarting wait_for_event entered and waiting set_event entered but about to sleep set_event waking up and setting event set_event event set wait_for_event event is settrue done to change this to use threads we would merely need to change the import and to create two threadsfrom threading import threadevent print('starting'event event( thread(target=wait_for_eventargs=[event] start( thread(target=set_eventargs=[event] start( join(print('done' synchronising concurrent code it is not uncommon to need to ensure that critical regions of code are protected from concurrent execution by multiple threads or processes these blocks of code typically involve the modification ofor access toshared data it is therefore necessary to ensure that only one thread or process is updating shared object at time and that consumer threads or processes are blocked while this update is occurring this situation is most common where one or more threads or processes are the producers of data and one or more other threads or processes are the consumers of that data this is illustrated in the following diagram