Search code examples
multithreadingconcurrencysynchronizationmutexbarrier

What is the name of this synchronisation method?


I have a special programming construct that allows threads to wait until another thread releases all waiting threads at once. Each thread can register itself to wait for an external event that can be triggered by another thread (for example one that listens for user input). Once that event occurs all threads can continue and are immediately deregistered.

My question is: What is a construct like this called?

At first I thought of mutex, but as far as i know a mutex is a construct that only allows one thread to run at once (See this link https://www.quora.com/Semaphore-vs-mutex-vs-monitor-What-are-the-differences).

To me this construct sounds like a phaser in java, but my construct does not have a counting logic, so I was wondering what the correct wording is.


Solution

  • The correct answer is: this is mostly like a condition variable of a monitor. Quoting Wikipedia:

    A condition variable essentially is a container of threads that are waiting for a certain condition. Monitors provide a mechanism for threads to temporarily give up exclusive access in order to wait for some condition to be met, before regaining exclusive access and resuming their task.

    An example implementation of this is Java's wait and notifyAll.