inter thread/process synchronisation the barrier class itself provides several methods used to manage or find out information about the barriermethod description wait(timeout=nonewait until all threads have notified the barrier (unless timeout is reached)--returns the number of threads that passed the barrier return barrier to default state put the barrier into broken state return the number of threads required to pass the barrier number of threads currently waiting reset(abort(parties n_waiting barrier object can be reused any number of times for the same number of threads the above example could easily be changed to run using process by altering the import statement and creating set of processes instead of threadsfrom multiprocessing import barrierprocess print('main starting' barrier( callbackt process(target=print_itargs=(' ' )note that you should only use threads with threading barrier in turn you should only use processes with multiprocessing barrier event signalling although the point of using multiple threads or processes is to execute separate operations concurrentlythere are times when it is important to be able to allow two or more threads or processes to cooperate on the timing of their behaviour the barrier object presented above is relatively high-level way to do thishoweverin some cases finer grained control is required the threading event or multiprocessing event classes can be used for this purpose an event manages an internal flag that callers can either set(or clear(other threads can wait(for the flag to be set()effectively blocking their own progress until allowed to continue by the event the internal flag is initially set to false which ensures that if task gets to the event before it is set then it must wait you can infact invoke wait with an optional timeout if you do not include the optional timeout then wait(will wait forever while wait(timeoutwill wait up to the timeout given in seconds if the time out is reachedthen the wait method returns falseotherwise wait returns true as an examplethe following diagram illustrates two processes sharing an event object the first process runs function that waits for the event to be set in turn the second process runs function that will set the event and thus release the waiting process