Reputation:
Could you explain the point of difference between variable initialization sequence if a program starts and does not start a thread?
sec. 3.6.2/3 N3797 c++14 working draft:
If a program starts a thread (30.3), the subsequent initialization of a variable is unsequenced with respect to the initialization of a variable defined in a different translation unit. Otherwise, the initialization of a variable is indeterminately sequenced with respect to the initialization of a variable defined in a different translation unit.
Please, give an example, explaining that rule, if it possible.
Upvotes: 0
Views: 49
Reputation: 254631
Unsequenced means there is no sequence - the variables could be initialised concurrently, on different threads.
Indeterminately sequenced means that one is sequenced before the other - the variables are initialised sequentially, on the same thread - but it's not specified which is initialised first.
Upvotes: 1