V2EX  ›  英汉词典
Enqueued related words: Data-race, Memory-model

Happens-before

Definition / 定义

happens-before:并发与内存模型中的一个关键关系,表示在可见性与顺序性上,事件A“先发生于”事件B——也就是说,A的结果(例如写入的值)在B中应当是可见的,并且系统必须保证这种先后顺序不会被打破。常用于解释线程之间的同步数据竞争问题。(在不同语言/平台的内存模型中,细节略有差异。)

Pronunciation / 发音

/ˌhæpənz bɪˈfɔːr/

Examples / 例句

A lock release happens-before a later lock acquire on the same mutex.
对同一把互斥锁而言,“解锁”在内存模型中先发生于之后的“加锁”。

If the write happens-before the read, the second thread must observe the updated value, even if the CPU reorders other instructions.
如果写入先发生于读取,那么第二个线程必须看到更新后的值,即使CPU对其他指令进行了重排序。

Etymology / 词源

该术语由 happen(发生)before(在……之前)构成,直译为“先发生”。在并发领域中,它被赋予了形式化含义:不仅是时间上的先后,更强调在内存可见性执行顺序约束上的“先后保证”。这一概念在现代编程语言的内存模型(如 Java、C++)中被系统化使用。

Related Words / 相关词

Literary Works / 文学作品

  • Java Concurrency in Practice(《Java 并发编程实战》)
  • The Java Language Specification(《Java 语言规范》,内存模型章节)
  • C++ Concurrency in Action(《C++ 并发编程实战》)
  • The Art of Multiprocessor Programming(《多处理器编程的艺术》)
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   749 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 14ms · UTC 22:51 · PVG 06:51 · LAX 14:51 · JFK 17:51
♥ Do have faith in what you're doing.