Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Partial Ordering" and Happens-before relation java

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 )

like image 989
nish1013 Avatar asked Oct 01 '13 16:10

nish1013


1 Answers

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.

like image 138
Eran Avatar answered Sep 22 '22 02:09

Eran