V2EX  ›  英汉词典
Enqueued related words: Spurious Wakeup

Condition Variable

释义 Definition

条件变量:并发编程中的一种同步原语,允许线程在某个条件尚未满足时进入等待状态,并在其他线程发出通知(signal/broadcast)后被唤醒,通常与互斥锁(mutex)配合使用,以安全地检查与更新共享状态。(也常简称 condvar

例句 Examples

The worker thread waits on a condition variable until there is a new task.
工作线程在条件变量上等待,直到有新的任务到来。

To avoid busy-waiting, the program uses a mutex plus a condition variable so that consumers sleep when the queue is empty and wake up when producers enqueue items.
为避免忙等,程序使用互斥锁配合条件变量:当队列为空时消费者休眠,当生产者入队时再将其唤醒。

发音 Pronunciation (IPA)

/kənˈdɪʃən ˈvɛriəbəl/

词源 Etymology

Condition 来自拉丁语 condicio(“条件、约定”),variable 来自拉丁语 variabilis(“可变化的”)。合起来在计算机并发语境中表示:线程等待的是某个“条件(状态)”,而该条件会随程序运行而“变化”,因此用一种机制来在条件变化时通知等待者。

相关词 Related Words

文学与经典著作中的用例 Literary / Notable Works

  • 《The Linux Programming Interface》(Michael Kerrisk):在 POSIX 线程同步章节中讨论 condition variables 的用法与注意事项。
  • 《Operating Systems: Three Easy Pieces》(Remzi & Andrea Arpaci-Dusseau):在并发与条件同步内容中讲解条件变量的 wait/signal 模式。
  • 《Advanced Programming in the UNIX Environment》(W. Richard Stevens 等):涉及 pthread 条件变量与线程协调的示例与说明。
  • 《The C++ Programming Language》(Bjarne Stroustrup):在并发支持相关内容中提到与条件变量(C++ 标准库 std::condition_variable)有关的同步思想。
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   1022 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 22ms · UTC 17:23 · PVG 01:23 · LAX 09:23 · JFK 12:23
♥ Do have faith in what you're doing.