10.10 Execution order

王朝other·作者佚名  2006-01-10
窄屏简体版  字體: |||超大  

10.10 Execution order

Execution shall proceed such that the side effects of each executing thread

are preserved at critical execution

points. A side effect is defined as a read or write of a volatile field, a

write to a non-volatile variable, a write

to an external resource, and the throwing of an exception. The critical

execution points at which the order of

these side effects must be preserved are references to volatile fields (?7.4

.3), lock statements (?5.12), and

thread creation and termination. An implementation is free to change the

order of execution of a

C# program, subject to the following constraints:

?Data dependence is preserved within a thread of execution. That is, the

value of each variable is

computed as if all statements in the thread were executed in original

program order.

?Initialization ordering rules are preserved (?7.4.4 and ?7.4.5).

?The ordering of side effects is preserved with respect to volatile reads

and writes (?7.4.3). Additionally,

an implementation need not evaluate part of an expression if it can deduce

that that expression.s value is

not used and that no needed side effects are produced (including any caused

by calling a method or

accessing a volatile field). When program execution is interrupted by an

asynchronous event (such as an

exception thrown by another thread), it is not guaranteed that the

observable side effects are visible in

the original program order.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有  導航