“部分订购";和发生前关系java [英] "Partial Ordering" and Happens-before relation java
问题描述
我正在阅读 Java并发实践 >
我对事前发生关系的具体解释感到困惑.
它表明,
操作是通过偏序进行排序的,该事件称为事前发生
部分订购" 到底是什么意思?
(书中有一个解释,但我不清楚)
部分排序意味着并非每对操作都具有关系happens-before
.
实际上,并非每对操作都具有这种关系这一事实使您可以同时执行操作.
例如,假设您有操作A,B,C和A; D.
我们可以定义部分排序:A must happen before B and C
.
然后,A和B以及A和C具有happens-before
关系.
但是,A和D没有这种关系,因此D可以在A之前,A之后或在A执行期间执行.
另一方面,如果happens-before
是完整顺序,例如A happens-before B happens-before C happens-before D
(请注意,在这种情况下,对于每一对操作,您都知道哪个发生在另一个操作之前,因此它是完整的排序),那么这些操作必须是串行执行的,并且并发是不可能的.
I am reading Java Concurrency in Practice
I am confused with the specific explanation regarding happens-before relationship.
It states that,
operations are ordered by a partial ordering called happens-before
What exactly does this mean by "partial ordering"?
(There is an explanation in the book but its not clear to me )
Partial Ordering means that not every pair of operations has the relation happens-before
.
Actually, the fact that not every pair of operations has that relation enables you to perform operations concurrently.
For example, suppose you have operations A, B, C & D.
We can define a partial ordering: A must happen before B and C
.
Then A and B have the happens-before
relation, as do A and C.
However, A and D don't have that relation, so D can be executed either before A, after A or while A is being executed.
If, on the other hand, happens-before
was a full ordering, such as A happens-before B happens-before C happens-before D
(note that in this case, for each pair of operations you know which one happens-before the other, hence it is a full ordering), then the execution of the operations would have to be serial, and no concurrency would be possible.
这篇关于“部分订购";和发生前关系java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!