这种同步方法的名称是什么?

What is the name of this synchronisation method?

我有一个特殊的编程结构,允许线程等待直到另一个线程立即释放所有等待的线程。 每个线程都可以注册自己以等待可以由另一个线程(例如侦听用户输入的线程)触发的外部事件。一旦该事件发生,所有线程都可以继续并立即注销。

我的问题是:这样的结构叫什么?

起初我想到了互斥量,但据我所知,互斥量是一种只允许一个线程一次 运行 的构造(参见 link https://www.quora.com/Semaphore-vs-mutex-vs-monitor-What-are-the-differences) .

对我来说,这个构造听起来像是 java 中的移相器,但我的构造没有计数逻辑,所以我想知道正确的措辞是什么。

相关 Java 和 C# 类 中有单词 "barrier",所以这可能就是您想要的。

正确答案是:这很像监视器的条件变量。引用 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.

Java 的 wait and notifyAll.

的示例实现